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



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

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

#model_localized_attr_name(locale) ⇒ Object



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

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

#model_typeObject



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

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

#model_validatorsObject



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

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