Class: Dozer::Rule
- Inherits:
-
Object
- Object
- Dozer::Rule
- Defined in:
- lib/dozer/rule.rb
Instance Attribute Summary collapse
-
#base_klass ⇒ Object
Returns the value of attribute base_klass.
-
#from ⇒ Object
Returns the value of attribute from.
-
#func ⇒ Object
Returns the value of attribute func.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #apply(input) ⇒ Object
-
#initialize(options) ⇒ Rule
constructor
A new instance of Rule.
Constructor Details
#initialize(options) ⇒ Rule
Returns a new instance of Rule.
5 6 7 8 9 10 11 12 13 |
# File 'lib/dozer/rule.rb', line 5 def initialize() = .with_indifferent_access validate!() @base_klass = [:base_klass] @from = [:from].to_sym @to = [:to].to_sym @func = [:func] end |
Instance Attribute Details
#base_klass ⇒ Object
Returns the value of attribute base_klass.
3 4 5 |
# File 'lib/dozer/rule.rb', line 3 def base_klass @base_klass end |
#from ⇒ Object
Returns the value of attribute from.
3 4 5 |
# File 'lib/dozer/rule.rb', line 3 def from @from end |
#func ⇒ Object
Returns the value of attribute func.
3 4 5 |
# File 'lib/dozer/rule.rb', line 3 def func @func end |
#to ⇒ Object
Returns the value of attribute to.
3 4 5 |
# File 'lib/dozer/rule.rb', line 3 def to @to end |
Instance Method Details
#apply(input) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/dozer/rule.rb', line 15 def apply(input) if applicable?(input) [to, evaluate(input[from])] else nil end end |