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
-
#column_for_attribute(name) ⇒ Object
Delegate column for attribute to the model to support simple_form’s attribute type interrogation.
- #defined_enums ⇒ Object
- #has_attribute?(name) ⇒ Boolean
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.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.
23 24 25 |
# File 'lib/reform/form/active_model/model_reflections.rb', line 23 def column_for_attribute(name) model_for_property(name).column_for_attribute(name) end |
#defined_enums ⇒ Object
31 32 33 34 35 |
# File 'lib/reform/form/active_model/model_reflections.rb', line 31 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
27 28 29 |
# File 'lib/reform/form/active_model/model_reflections.rb', line 27 def has_attribute?(name) model_for_property(name).has_attribute?(name) end |