Class: Arbre::Context

Inherits:
HTML::Element show all
Defined in:
lib/active_admin/arbre/context.rb

Instance Attribute Summary

Attributes inherited from HTML::Element

#children, #parent

Instance Method Summary collapse

Methods inherited from HTML::Element

#+, #<<, #add_child, #assigns, #build, builder_method, #content, #content=, #document, #each, #get_elements_by_class_name, #get_elements_by_tag_name, #helpers, #html_safe, #initialize, #parent?, #remove_child, #tag_name, #to_ary, #to_s, #to_str

Methods included from Builder::BuilderMethods

#append_return_block, #build_tag, #current_dom_context, #insert_tag, #with_current_dom_context

Methods included from Builder

#current_dom_context, #helpers

Constructor Details

This class inherits a constructor from Arbre::HTML::Element

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Webservers treat Arbre::Context as a string. We override method_missing to delegate to the string representation of the html.



22
23
24
25
26
27
28
# File 'lib/active_admin/arbre/context.rb', line 22

def method_missing(method, *args, &block)
  if cached_html.respond_to? method
    cached_html.send method, *args, &block
  else
    super
  end
end

Instance Method Details

#bytesizeObject Also known as: length



10
11
12
# File 'lib/active_admin/arbre/context.rb', line 10

def bytesize
  cached_html.bytesize
end

#indent_levelObject



5
6
7
8
# File 'lib/active_admin/arbre/context.rb', line 5

def indent_level
  # A context does not increment the indent_level
  super - 1
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/active_admin/arbre/context.rb', line 15

def respond_to?(method)
  super || cached_html.respond_to?(method)
end