class Rectify::FormAttribute

Public Instance Methods

value_from(model_value) click to toggle source
# File lib/rectify/form_attribute.rb, line 3
def value_from(model_value)
  return declared_class.from_model(model_value) if form_object?

  if collection_of_form_objects?
    return model_value.map { |child| element_class.from_model(child) }
  end

  model_value
end

Private Instance Methods

collection?() click to toggle source
# File lib/rectify/form_attribute.rb, line 23
def collection?
  type.respond_to?(:member_type)
end
collection_of_form_objects?() click to toggle source
# File lib/rectify/form_attribute.rb, line 19
def collection_of_form_objects?
  collection? && element_class.respond_to?(:from_model)
end
declared_class() click to toggle source
# File lib/rectify/form_attribute.rb, line 31
def declared_class
  primitive
end
element_class() click to toggle source
# File lib/rectify/form_attribute.rb, line 27
def element_class
  type.member_type
end
form_object?() click to toggle source
# File lib/rectify/form_attribute.rb, line 15
def form_object?
  declared_class.respond_to?(:from_model)
end