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

Returns a new instance of Scope.



184
185
186
187
188
189
# File 'lib/ab_admin/config/base.rb', line 184

def initialize(name, options={}, &block)
  @name = name
  @options = options
  @options[:badge] = {} if @options[:badge] && !@options[:badge].is_a?(Hash)
  @data = block
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



182
183
184
# File 'lib/ab_admin/config/base.rb', line 182

def data
  @data
end

#nameObject (readonly)

Returns the value of attribute name.



182
183
184
# File 'lib/ab_admin/config/base.rb', line 182

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



182
183
184
# File 'lib/ab_admin/config/base.rb', line 182

def options
  @options
end

Instance Method Details

#apply(context, relation) ⇒ Object



195
196
197
# File 'lib/ab_admin/config/base.rb', line 195

def apply(context, relation)
  data.is_a?(Proc) ? data.call(context, relation) : relation.public_send(name)
end

#param_nameObject



191
192
193
# File 'lib/ab_admin/config/base.rb', line 191

def param_name
  options[:as] || name
end