Class: AbAdmin::Config::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/ab_admin/config/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}, &block) ⇒ Scope



164
165
166
167
168
# File 'lib/ab_admin/config/base.rb', line 164

def initialize(name, options={}, &block)
  @name = name
  @options = options
  @data = block
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data



162
163
164
# File 'lib/ab_admin/config/base.rb', line 162

def data
  @data
end

#nameObject (readonly)

Returns the value of attribute name



162
163
164
# File 'lib/ab_admin/config/base.rb', line 162

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options



162
163
164
# File 'lib/ab_admin/config/base.rb', line 162

def options
  @options
end

Instance Method Details

#apply(relation, params) ⇒ Object



170
171
172
173
# File 'lib/ab_admin/config/base.rb', line 170

def apply(relation, params)
  return relation unless params[name].present?
  data.is_a?(Proc) ? data.call(relation, params) : relation.public_send(name)
end