Class: Poncho::Params::ResourceParam
- Inherits:
-
Poncho::Param
- Object
- Poncho::Param
- Poncho::Params::ResourceParam
- Defined in:
- lib/poncho/params/resource.rb
Instance Attribute Summary
Attributes inherited from Poncho::Param
Instance Method Summary collapse
- #convert(value) ⇒ Object
-
#initialize(name, options = {}) ⇒ ResourceParam
constructor
A new instance of ResourceParam.
- #validate_each(record, attribute, value) ⇒ Object
Methods inherited from Poncho::Param
Constructor Details
#initialize(name, options = {}) ⇒ ResourceParam
Returns a new instance of ResourceParam.
4 5 6 7 8 9 10 |
# File 'lib/poncho/params/resource.rb', line 4 def initialize(name, = {}) super unless [:resource] throw ArgumentError, ':resource required' end end |
Instance Method Details
#convert(value) ⇒ Object
22 23 24 |
# File 'lib/poncho/params/resource.rb', line 22 def convert(value) [:resource].new(value) end |
#validate_each(record, attribute, value) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/poncho/params/resource.rb', line 12 def validate_each(record, attribute, value) resource = convert(value) unless resource.valid? resource.errors.to_hash.each do |attr, | record.[:"#{attribute}[#{attr}]"] |= end end end |