Class: Melitta::Coercers::Tree

Inherits:
Struct
  • Object
show all
Defined in:
lib/melitta/coercers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#inputObject

Returns the value of attribute input

Returns:

  • (Object)

    the current value of input



112
113
114
# File 'lib/melitta/coercers.rb', line 112

def input
  @input
end

Instance Method Details

#errorsObject



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

#originObject



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

#outputObject



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

Returns:



128
129
130
# File 'lib/melitta/coercers.rb', line 128

def valid?
  input.all? { |k,v| v.valid? }
end