Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sonots/acts_as_parameter_object
Acts as a Prameter Object. cf. Refactoring: Ruby Edition
https://github.com/sonots/acts_as_parameter_object
Last synced: about 2 months ago
JSON representation
Acts as a Prameter Object. cf. Refactoring: Ruby Edition
- Host: GitHub
- URL: https://github.com/sonots/acts_as_parameter_object
- Owner: sonots
- License: mit
- Created: 2013-08-01T04:40:33.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-08-03T17:12:15.000Z (over 11 years ago)
- Last Synced: 2024-10-13T08:08:39.725Z (3 months ago)
- Language: Ruby
- Size: 117 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# acts_as_parameter_object
testing ruby: 1.9.3, 2.0.0
## About acts_as_parameter_object
ActsAsParameterObject creates a model which acts as a Parameter Object. cf. [Refactoring: Ruby Edition](http://www.amazon.com/dp/0321603508).
## Example
```ruby
class ParameterObjectExample
include ActsAsParameterObjectattr_accessor :title
validates_presence_of :titledef initialize(params = {})
@title = params[:title]
end
endParameterObjectExample.new(:foo => 'bar').valid? #=> false
```You can use all of ActiveModel::Validations methods.
I use a parameter object as a validator model for params coming from rails controller.
In contrast to ActiveRecord, this model does not access to the database.## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new [Pull Request](../../pull/new/master)## Copyright
Copyright (c) 2013 Naotoshi SEO. See [LICENSE](LICENSE) for details.