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

#in_index(&block) ⇒ Object

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

“‘ruby

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

“‘



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

def in_index(&block)
  name  = controller_name
  path  = controller_path.gsub(name, '').gsub(/dashboard\//, '')
  model = "#{path}#{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