https://github.com/alexwayfer/formalism-model_forms
Standard Formalism forms for Sequel ModelsaStandard Formalism forms for Sequel Models, such like create, find, delete, etc.
https://github.com/alexwayfer/formalism-model_forms
Last synced: over 1 year ago
JSON representation
Standard Formalism forms for Sequel ModelsaStandard Formalism forms for Sequel Models, such like create, find, delete, etc.
- Host: GitHub
- URL: https://github.com/alexwayfer/formalism-model_forms
- Owner: AlexWayfer
- License: mit
- Created: 2020-07-09T21:39:13.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-04-29T07:10:45.000Z (about 2 years ago)
- Last Synced: 2024-04-29T08:29:34.492Z (about 2 years ago)
- Language: Ruby
- Homepage:
- Size: 136 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Formalism Model Forms
[](https://cirrus-ci.com/github/AlexWayfer/formalism-model_forms)
[](https://codecov.io/gh/AlexWayfer/formalism-model_forms)
[](https://codeclimate.com/github/AlexWayfer/formalism-model_forms)
[](https://depfu.com/repos/github/AlexWayfer/formalism-model_forms)
[](https://inch-ci.org/github/AlexWayfer/formalism-model_forms)
[](LICENSE.txt)
[](https://rubygems.org/gems/formalism-model_forms)
Ruby gem with standard [Formalism](https://github.com/AlexWayfer/formalism) forms
for ([Sequel](https://sequel.jeremyevans.net/)) models.
Used by [Flame Generate Toys](https://github.com/AlexWayfer/flame_generate_toys).
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'formalism-model_forms'
```
And then execute:
```shell
bundle install
```
Or install it yourself as:
```shell
gem install formalism-model_forms
```
## Usage
```ruby
# forms/_base.rb
require 'formalism/model_forms'
## Define base form and model forms via gem
module MyProject
module Forms
## Base class for forms
class Base < Formalism::Form
end
end
Formalism::ModelForms.define_for_project self
end
```
`.define_for_project` requires project namespace (`self` in the example above)
and allows such options:
* `:forms_namespace`, default is `project_namespace::Forms`
* `:models_namespace`, default is `project_namespace::Models`
```ruby
# forms/user/create.rb
module MyProject
module Forms
module User
class Create < Formalism::ModelForms::Create
field :name
private
def validate
errors.add 'Name is not provided' if name.to_s.empty?
end
# `execute` is inherited from `Formalism::ModelForms`
end
end
end
end
```
## Development
After checking out the repo, run `bundle install` to install dependencies.
Then, run `toys rspec` to run the tests.
To install this gem onto your local machine, run `toys gem install`.
To release a new version, run `toys gem release %version%`.
See how it works [here](https://github.com/AlexWayfer/gem_toys#release).
## Contributing
Bug reports and pull requests are welcome on [GitHub](https://github.com/AlexWayfer/formalism).
## License
The gem is available as open source under the terms of the
[MIT License](https://opensource.org/licenses/MIT).