Class: Olivander::Components::TablePortletComponent::Builder

Inherits:
Object
  • Object
show all
Defined in:
app/components/olivander/components/table_portlet_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection, &block) ⇒ Builder

Returns a new instance of Builder.



43
44
45
46
# File 'app/components/olivander/components/table_portlet_component.rb', line 43

def initialize(collection, &block)
  self.field_blocks = []
  block.call(self) if block_given?
end

Instance Attribute Details

#field_blocksObject

Returns the value of attribute field_blocks.



41
42
43
# File 'app/components/olivander/components/table_portlet_component.rb', line 41

def field_blocks
  @field_blocks
end

Returns the value of attribute footer_buttons.



41
42
43
# File 'app/components/olivander/components/table_portlet_component.rb', line 41

def footer_buttons
  @footer_buttons
end

#header_toolsObject

Returns the value of attribute header_tools.



41
42
43
# File 'app/components/olivander/components/table_portlet_component.rb', line 41

def header_tools
  @header_tools
end

Instance Method Details

#field(key, alignment = 'text-left', &block) ⇒ Object



48
49
50
51
52
53
# File 'app/components/olivander/components/table_portlet_component.rb', line 48

def field(key, alignment = 'text-left', &block)
  unless block_given?
    block = Proc.new{ |x| x.send(key).to_s.html_safe }
  end
  field_blocks << OpenStruct.new(key: key, alignment: alignment, block: block)
end


59
60
61
# File 'app/components/olivander/components/table_portlet_component.rb', line 59

def with_footer_buttons(&block)
  self.footer_buttons = block
end

#with_header_tools(&block) ⇒ Object



55
56
57
# File 'app/components/olivander/components/table_portlet_component.rb', line 55

def with_header_tools(&block)
  self.header_tools = block
end