Class: Dominate::Scope
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#instance ⇒ Object
Returns the value of attribute instance.
-
#root_doc ⇒ Object
Returns the value of attribute root_doc.
Instance Method Summary collapse
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config
2 3 4 |
# File 'lib/dominate/scope.rb', line 2 def config @config end |
#instance ⇒ Object
Returns the value of attribute instance
2 3 4 |
# File 'lib/dominate/scope.rb', line 2 def instance @instance end |
#root_doc ⇒ Object
Returns the value of attribute root_doc
2 3 4 |
# File 'lib/dominate/scope.rb', line 2 def root_doc @root_doc end |
Instance Method Details
#apply(data, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/dominate/scope.rb', line 4 def apply data, &block root_doc.each do |doc| if data.is_a? Array doc = apply_list doc, data, &block else doc = apply_data doc, data, &block end end root_doc end |
#apply_instance ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dominate/scope.rb', line 16 def apply_instance root_doc.traverse do |x| if defined?(x.attributes) && x.attributes.keys.include?('data-instance') method = x.attr 'data-instance' begin x.inner_html = instance.instance_eval method rescue x.inner_html = '' end end end root_doc end |