Class: Operations::Form::Attribute
- Inherits:
-
Object
- Object
- Operations::Form::Attribute
- Extended by:
- Dry::Initializer
- Defined in:
- lib/operations/form/attribute.rb
Overview
The main purpose is to infer attribute properties from the related model. We need it to automate form rendering for the legacy UI.
Instance Method Summary collapse
- #model_attribute ⇒ Object
- #model_class ⇒ Object
- #model_human_name(options = {}) ⇒ Object
- #model_type ⇒ Object
- #model_validators ⇒ Object
Instance Method Details
#model_attribute ⇒ Object
22 23 24 25 26 |
# File 'lib/operations/form/attribute.rb', line 22 def model_attribute return @model_attribute if defined?(@model_attribute) @model_attribute = model_class && (model_name.to_s.split("#").second.presence || name.to_s) end |
#model_class ⇒ Object
16 17 18 19 20 |
# File 'lib/operations/form/attribute.rb', line 16 def model_class return @model_class if defined?(@model_class) @model_class = model_name.is_a?(String) ? model_name.split("#").first.constantize : model_name end |
#model_human_name(options = {}) ⇒ Object
32 33 34 |
# File 'lib/operations/form/attribute.rb', line 32 def model_human_name( = {}) model_class.human_attribute_name(model_attribute, ) if model_name end |
#model_type ⇒ Object
28 29 30 |
# File 'lib/operations/form/attribute.rb', line 28 def model_type model_class.type_for_attribute(model_attribute) if model_name end |
#model_validators ⇒ Object
36 37 38 |
# File 'lib/operations/form/attribute.rb', line 36 def model_validators model_name ? model_class.validators_on(model_attribute) : [] end |