Class: Operations::Form::Attribute

Inherits:
Object
  • Object
show all
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

Instance Method Details

#model_human_name(options = {}) ⇒ Object



22
23
24
# File 'lib/operations/form/attribute.rb', line 22

def model_human_name(options = {})
  owning_model.human_attribute_name(string_name, options) if model_name
end

#model_localized_attr_name(locale) ⇒ Object



30
31
32
# File 'lib/operations/form/attribute.rb', line 30

def model_localized_attr_name(locale)
  owning_model.localized_attr_name_for(string_name, locale) if model_name
end

#model_typeObject



18
19
20
# File 'lib/operations/form/attribute.rb', line 18

def model_type
  @model_type ||= owning_model.type_for_attribute(string_name) if model_name
end

#model_validatorsObject



26
27
28
# File 'lib/operations/form/attribute.rb', line 26

def model_validators
  @model_validators ||= model_name ? owning_model.validators_on(string_name) : []
end