Module: Reform::Form::ActiveModel::ModelReflections

Defined in:
lib/reform/form/active_model/model_reflections.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
11
# File 'lib/reform/form/active_model/model_reflections.rb', line 8

def self.included(base)
  base.extend ClassMethods
  base.send :register_feature, self # makes it work in nested forms.
end

Instance Method Details

#column_for_attribute(name) ⇒ Object

Delegate column for attribute to the model to support simple_form’s attribute type interrogation.



28
29
30
# File 'lib/reform/form/active_model/model_reflections.rb', line 28

def column_for_attribute(name)
  model_for_property(name).column_for_attribute(name)
end

#defined_enumsObject



36
37
38
39
40
# File 'lib/reform/form/active_model/model_reflections.rb', line 36

def defined_enums
  return model.defined_enums unless is_a?(Reform::Form::Composition)

  mapper.each.with_object({}) { |m,h| h.merge! m.defined_enums }
end

#has_attribute?(name) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/reform/form/active_model/model_reflections.rb', line 32

def has_attribute?(name)
  model_for_property(name).has_attribute?(name)
end