Sha256: 8b2d9e8ba5c03a27978b2b4796e4376dd80f1eefc8bd0c8dffc0ec9b2f6d97eb

Contents?: true

Size: 828 Bytes

Versions: 27

Compression:

Stored size: 828 Bytes

Contents

module DynamicScaffold
  module List
    class Item
      attr_reader :classnames, :html_attributes

      def initialize(config, *args, block)
        @config = config
        @html_attributes = args.extract_options!
        @classnames = @html_attributes.delete(:class)
        @attribute_name = args[0]
        @block = block
      end

      def value(view, record)
        if @block
          view.instance_exec(record, @attribute_name, &@block)
        else
          record.public_send(@attribute_name)
        end
      end

      def label(label = nil, &block)
        @block = block if block
        if label
          @label = label
          self
        elsif @label
          @label
        elsif @attribute_name
          @config.model.human_attribute_name @attribute_name
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
dynamic_scaffold-0.10.1 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.10.0 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.9.2 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.9.1 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.9.0 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.8.5 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.8.4 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.8.3 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.8.2 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.8.1 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.8.0 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.7.1 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.7.0 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.6.1 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.6.0 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.5.0 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.4.2 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.4.1 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.4.0 lib/dynamic_scaffold/list/item.rb
dynamic_scaffold-0.3.1 lib/dynamic_scaffold/list/item.rb