Class: Motion::MarkupTransformer
- Inherits:
-
Object
- Object
- Motion::MarkupTransformer
- Defined in:
- lib/motion/markup_transformer.rb
Instance Attribute Summary collapse
-
#key_attribute ⇒ Object
readonly
Returns the value of attribute key_attribute.
-
#serializer ⇒ Object
readonly
Returns the value of attribute serializer.
-
#state_attribute ⇒ Object
readonly
Returns the value of attribute state_attribute.
Instance Method Summary collapse
- #add_state_to_html(component, html) ⇒ Object
-
#initialize(serializer: Motion.serializer, key_attribute: Motion.config.key_attribute, state_attribute: Motion.config.state_attribute) ⇒ MarkupTransformer
constructor
A new instance of MarkupTransformer.
Constructor Details
#initialize(serializer: Motion.serializer, key_attribute: Motion.config.key_attribute, state_attribute: Motion.config.state_attribute) ⇒ MarkupTransformer
Returns a new instance of MarkupTransformer.
14 15 16 17 18 19 20 21 22 |
# File 'lib/motion/markup_transformer.rb', line 14 def initialize( serializer: Motion.serializer, key_attribute: Motion.config.key_attribute, state_attribute: Motion.config.state_attribute ) @serializer = serializer @key_attribute = key_attribute @state_attribute = state_attribute end |
Instance Attribute Details
#key_attribute ⇒ Object (readonly)
Returns the value of attribute key_attribute.
10 11 12 |
# File 'lib/motion/markup_transformer.rb', line 10 def key_attribute @key_attribute end |
#serializer ⇒ Object (readonly)
Returns the value of attribute serializer.
10 11 12 |
# File 'lib/motion/markup_transformer.rb', line 10 def serializer @serializer end |
#state_attribute ⇒ Object (readonly)
Returns the value of attribute state_attribute.
10 11 12 |
# File 'lib/motion/markup_transformer.rb', line 10 def state_attribute @state_attribute end |
Instance Method Details
#add_state_to_html(component, html) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/motion/markup_transformer.rb', line 24 def add_state_to_html(component, html) return if html.blank? key, state = serializer.serialize(component) transform_root(component, html) do |root| root[key_attribute] = key root[state_attribute] = state end end |