Class: Melitta::Coercers::Tree
- Inherits:
-
Struct
- Object
- Struct
- Melitta::Coercers::Tree
- Defined in:
- lib/melitta/coercers.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
Returns the value of attribute input.
Instance Method Summary collapse
Instance Attribute Details
#input ⇒ Object
Returns the value of attribute input
112 113 114 |
# File 'lib/melitta/coercers.rb', line 112 def input @input end |
Instance Method Details
#errors ⇒ Object
120 121 122 123 124 125 126 |
# File 'lib/melitta/coercers.rb', line 120 def errors input.each_with_object({}) do |(k,v), hsh| unless v.valid? hsh[k] = v.respond_to?(:errors) ? v.errors : I18n.t("errors.coercers.#{v.class.name.demodulize.downcase}") end end end |
#origin ⇒ Object
114 115 116 117 118 |
# File 'lib/melitta/coercers.rb', line 114 def origin input.each_with_object({}) do |(k,v), hsh| hsh[k] = v.respond_to?(:origin) ? v.origin : v.input end end |
#output ⇒ Object
132 133 134 135 136 |
# File 'lib/melitta/coercers.rb', line 132 def output input.each_with_object({}) do |(k,v), hsh| hsh[k] = v.output end end |
#valid? ⇒ Boolean
128 129 130 |
# File 'lib/melitta/coercers.rb', line 128 def valid? input.all? { |k,v| v.valid? } end |