Class: Views::Resources::ShowHasMany::Column

Inherits:
Object
  • Object
show all
Defined in:
app/views/resources/show_has_many.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &content_for_block) ⇒ Column

Returns a new instance of Column.



4
5
6
7
# File 'app/views/resources/show_has_many.rb', line 4

def initialize(name, &content_for_block)
  @name = name
  @content_for_block = content_for_block
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



3
4
5
# File 'app/views/resources/show_has_many.rb', line 3

def name
  @name
end

Instance Method Details

#content_for(context, item) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'app/views/resources/show_has_many.rb', line 9

def content_for(context, item)
  content = if @content_for_block
    context.instance_exec(item, &@content_for_block)
  else
    item.send(name)
  end
  
  context.text content if content.is_a?(String)
end