Class: DisplayFor::Builder::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/display_for/builder/base.rb

Direct Known Subclasses

CollectionBase, ResourceBase

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html_options, template, &block) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
13
14
15
# File 'lib/display_for/builder/base.rb', line 8

def initialize(html_options, template, &block)
  @template = template
  @attributes = []
  @actions = []
  @html_options = html_options

  block.call(self) if block_given?
end

Instance Attribute Details

#html_optionsObject (readonly)

Returns the value of attribute html_options.



4
5
6
# File 'lib/display_for/builder/base.rb', line 4

def html_options
  @html_options
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



4
5
6
# File 'lib/display_for/builder/base.rb', line 4

def namespace
  @namespace
end

#resource_classObject (readonly)

Returns the value of attribute resource_class.



4
5
6
# File 'lib/display_for/builder/base.rb', line 4

def resource_class
  @resource_class
end

#templateObject (readonly)

Returns the value of attribute template.



4
5
6
# File 'lib/display_for/builder/base.rb', line 4

def template
  @template
end

Instance Method Details

#action(name, options = {}, &block) ⇒ Object



21
22
23
# File 'lib/display_for/builder/base.rb', line 21

def action(name, options = {}, &block)
  @actions << Element::Action.new(self, name, options, &block)
end

#attribute(name, options = {}, &block) ⇒ Object



17
18
19
# File 'lib/display_for/builder/base.rb', line 17

def attribute(name, options = {}, &block)
  @attributes << Element::Attribute.new(self, name, options, &block)
end

#html(name, options = {}, &block) ⇒ Object



25
26
27
# File 'lib/display_for/builder/base.rb', line 25

def html(name, options = {}, &block)
  @attributes << Element::Html.new(self, name, options, &block)
end