Sha256: 0900359f1e64015b630ca0dc8d1d9a1aed6779465bc4186be9f96457025b58f6
Contents?: true
Size: 576 Bytes
Versions: 2
Compression:
Stored size: 576 Bytes
Contents
module Xporter class Column attr_reader :attribute_name, :title, :block def initialize(attribute_name, title = nil, &block) @attribute_name = attribute_name @title = title @block = block || ->(model){ model.public_send(attribute_name) } end def data(model) block.call(model) end def title_from(resource_class) return title if title.present? return attribute_name.to_s.titleize unless resource_class.respond_to?(:human_attribute_name) resource_class.human_attribute_name(attribute_name) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
xporter-0.2.0 | lib/xporter/column.rb |
xporter-0.1.0 | lib/xporter/column.rb |