Class: Avo::Dsl::FieldParser
- Inherits:
-
Object
- Object
- Avo::Dsl::FieldParser
- Defined in:
- lib/avo/dsl/field_parser.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#as ⇒ Object
readonly
Returns the value of attribute as.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#order_index ⇒ Object
readonly
Returns the value of attribute order_index.
Instance Method Summary collapse
-
#initialize(id:, order_index: 0, **args, &block) ⇒ FieldParser
constructor
A new instance of FieldParser.
- #invalid? ⇒ Boolean
- #parse ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(id:, order_index: 0, **args, &block) ⇒ FieldParser
Returns a new instance of FieldParser.
11 12 13 14 15 16 17 18 |
# File 'lib/avo/dsl/field_parser.rb', line 11 def initialize(id:, order_index: 0, **args, &block) @id = id @as = args.fetch(:as, :text) @order_index = order_index @args = args @block = block @instance = nil end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/avo/dsl/field_parser.rb', line 5 def args @args end |
#as ⇒ Object (readonly)
Returns the value of attribute as.
4 5 6 |
# File 'lib/avo/dsl/field_parser.rb', line 4 def as @as end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
7 8 9 |
# File 'lib/avo/dsl/field_parser.rb', line 7 def block @block end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/avo/dsl/field_parser.rb', line 6 def id @id end |
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
8 9 10 |
# File 'lib/avo/dsl/field_parser.rb', line 8 def instance @instance end |
#order_index ⇒ Object (readonly)
Returns the value of attribute order_index.
9 10 11 |
# File 'lib/avo/dsl/field_parser.rb', line 9 def order_index @order_index end |
Instance Method Details
#invalid? ⇒ Boolean
24 25 26 |
# File 'lib/avo/dsl/field_parser.rb', line 24 def invalid? !valid? end |
#parse ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/avo/dsl/field_parser.rb', line 28 def parse # The field is passed as a symbol eg: :text, :color_picker, :trix @instance = if as.is_a? Symbol parse_from_symbol elsif as.is_a? Class parse_from_class end self end |
#valid? ⇒ Boolean
20 21 22 |
# File 'lib/avo/dsl/field_parser.rb', line 20 def valid? instance.present? end |