Class: Formwandler::FieldDefinition
- Inherits:
-
Object
- Object
- Formwandler::FieldDefinition
- Defined in:
- lib/formwandler/field_definition.rb
Instance Attribute Summary collapse
-
#array ⇒ Object
readonly
Returns the value of attribute array.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#delocalize ⇒ Object
readonly
Returns the value of attribute delocalize.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#hidden ⇒ Object
readonly
Returns the value of attribute hidden.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #hidden_options ⇒ Object
- #hide_option(name, value = true) ⇒ Object
- #in_transformation ⇒ Object
-
#initialize(name, hidden: false, disabled: false, default: nil, delocalize: nil, model: nil, source: nil, options: nil, array: false) ⇒ FieldDefinition
constructor
A new instance of FieldDefinition.
- #out_transformation ⇒ Object
- #transform(&block) ⇒ Object
Constructor Details
#initialize(name, hidden: false, disabled: false, default: nil, delocalize: nil, model: nil, source: nil, options: nil, array: false) ⇒ FieldDefinition
Returns a new instance of FieldDefinition.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/formwandler/field_definition.rb', line 9 def initialize(name, hidden: false, disabled: false, default: nil, delocalize: nil, model: nil, source: nil, options: nil, array: false) @name = name @hidden = hidden @disabled = disabled @default = default @delocalize = delocalize @model = model @source = source || name @options = @array = array end |
Instance Attribute Details
#array ⇒ Object (readonly)
Returns the value of attribute array.
7 8 9 |
# File 'lib/formwandler/field_definition.rb', line 7 def array @array end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
7 8 9 |
# File 'lib/formwandler/field_definition.rb', line 7 def default @default end |
#delocalize ⇒ Object (readonly)
Returns the value of attribute delocalize.
7 8 9 |
# File 'lib/formwandler/field_definition.rb', line 7 def delocalize @delocalize end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
7 8 9 |
# File 'lib/formwandler/field_definition.rb', line 7 def disabled @disabled end |
#hidden ⇒ Object (readonly)
Returns the value of attribute hidden.
7 8 9 |
# File 'lib/formwandler/field_definition.rb', line 7 def hidden @hidden end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
7 8 9 |
# File 'lib/formwandler/field_definition.rb', line 7 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/formwandler/field_definition.rb', line 7 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/formwandler/field_definition.rb', line 7 def @options end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/formwandler/field_definition.rb', line 7 def source @source end |
Instance Method Details
#hidden_options ⇒ Object
25 26 27 |
# File 'lib/formwandler/field_definition.rb', line 25 def @hidden_options ||= {} end |
#hide_option(name, value = true) ⇒ Object
21 22 23 |
# File 'lib/formwandler/field_definition.rb', line 21 def hide_option(name, value = true) [name.to_s] = value end |
#in_transformation ⇒ Object
33 34 35 |
# File 'lib/formwandler/field_definition.rb', line 33 def in_transformation value_transformer&.in_transformation end |
#out_transformation ⇒ Object
37 38 39 |
# File 'lib/formwandler/field_definition.rb', line 37 def out_transformation value_transformer&.out_transformation end |
#transform(&block) ⇒ Object
29 30 31 |
# File 'lib/formwandler/field_definition.rb', line 29 def transform(&block) @value_transformer = FieldValueTransformer.new(&block) end |