Sha256: ed57c4dd8d0e5867192acb236a24b1d787c8b86a848055feaee3bc42ce06a2fd

Contents?: true

Size: 631 Bytes

Versions: 4

Compression:

Stored size: 631 Bytes

Contents

class Views::Resources::ShowHasMany
  class Column
    attr_accessor :name
    def initialize(name, &content_for_block)
      @name = name
      @content_for_block = content_for_block
    end
    
    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
  end
  attr_accessor :columns
  def initialize(&config)
    @columns = []
    instance_eval(&config)
  end
  
  def column(name, &block)
    self.columns << Column.new(name, &block)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alpha-simprini-engine-0.0.4 app/views/resources/show_has_many.rb
alpha-simprini-engine-0.0.3 app/views/resources/show_has_many.rb
alpha-simprini-engine-0.0.2 app/views/resources/show_has_many.rb
alpha-simprini-engine-0.0.1 app/views/resources/show_has_many.rb