Sha256: f43715c9e9b5417ea030a22f2b9bfb92622190d74d198439baf2b5e3ec577b80

Contents?: true

Size: 770 Bytes

Versions: 3

Compression:

Stored size: 770 Bytes

Contents

module Component
  class ResourceTable < Base
    def initialize(*args)
      super
      @rows           = {}
      @resource       = @options.delete(:resource)
      @resource_class = @resource.class
    end

    def row(name, options = {}, &block)
      options.reverse_merge!(block: block) if block_given?
      @rows[name] = options
    end

    def timestamps(options = {})
      row(:created_at, options)
      row(:updated_at, options)
    end

    def association(name, options = {}, &block)
      options.reverse_merge!(block: block) if block_given?
      @rows[name] = options
    end

    private

    def view_locals
      {
        rows:           @rows,
        resource:       @resource,
        resource_class: @resource_class
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-add_ons-2.0.2 app/components/component/resource_table.rb
rails-add_ons-2.0.1 app/components/component/resource_table.rb
rails-add_ons-2.0.0 app/components/component/resource_table.rb