Class: Formalist::Element::Attributes

Inherits:
Object
  • Object
show all
Defined in:
lib/formalist/element/attributes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Attributes

Creates an attributes object from the supplied hash.

Parameters:

  • attrs (Hash) (defaults to: {})

    hash of form element attributes



10
11
12
# File 'lib/formalist/element/attributes.rb', line 10

def initialize(attrs = {})
  @attrs = attrs
end

Instance Attribute Details

#attrsObject (readonly)

Returns the attributes hash.



5
6
7
# File 'lib/formalist/element/attributes.rb', line 5

def attrs
  @attrs
end

Instance Method Details

#to_astArray

Returns the attributes as an abstract syntax tree.

Returns:

  • (Array)

    the abstract syntax tree



17
18
19
# File 'lib/formalist/element/attributes.rb', line 17

def to_ast
  deep_to_ast(deep_simplify(attrs))
end