Class: Syaso::List

Inherits:
Base
  • Object
show all
Defined in:
lib/syaso/list.rb

Constant Summary collapse

ITEM_VIEW =

——————–# content

Syaso::ListItem

Instance Attribute Summary

Attributes inherited from Base

#content

Instance Method Summary collapse

Constructor Details

#initialize(context, content) ⇒ List

initialize instance

Parameters:

  • context (ActionView)
  • content (Array)


16
17
18
19
# File 'lib/syaso/list.rb', line 16

def initialize(context, content)
  super(context)
  self.content = content
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Syaso::Base

Instance Method Details

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

render container and iterate items

Parameters:

  • options (Hash) (defaults to: {})


36
37
38
39
40
41
42
43
# File 'lib/syaso/list.rb', line 36

def each(options = {}, &block)
  self._render(options) do |i|
    self.content.each do |i|
      yield(self.item_view(i))
    end
    ""
  end
end

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

render list

Parameters:

  • options (Hash) (defaults to: {})


24
25
26
27
28
29
30
31
# File 'lib/syaso/list.rb', line 24

def render(options = {}, &block)
  ops = options.delete(:item)||{}
  self.each(options) do |i|
    self.buffer do
      i.render(ops, &block)
    end
  end
end