Module: Faalis::Dashboard::Sections::ResourcesIndex::ClassMethods

Defined in:
lib/faalis/dashboard/sections/resources_index.rb

Overview

The actual DSL for index ages

Instance Method Summary (collapse)

Instance Method Details

- (Object) in_index(&block)

To specify any property and action for index section you must use in_index class method with block of properties. For example:

  class ExamplesController < Dashboard::Application
    in_index do
      attributes :name, :description
      action_button :close, label: 'Close', href: dashboard_example_close_path
    end
  end


88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/faalis/dashboard/sections/resources_index.rb', line 88

def in_index(&block)
  model = controller_name.classify.constantize
  index_props = Faalis::Dashboard::DSL::Index.new(model)

  unless block_given?
    fail ArgumentError, "You have to provide a block for 'in_index'"
  end

  define_method(:index_properties) do
    unless defined? @__index_props__
      instance_exec(index_props, &block)
      @__index_props__ = index_props
    end

    return @__index_props__
  end
end