Class: AbAdmin::Config::Scope
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #apply(context, relation) ⇒ Object
-
#initialize(name, options = {}, &block) ⇒ Scope
constructor
A new instance of Scope.
- #param_name ⇒ Object
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, ={}, &block) @name = name @options = @options[:badge] = {} if @options[:badge] && !@options[:badge].is_a?(Hash) @data = block end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
182 183 184 |
# File 'lib/ab_admin/config/base.rb', line 182 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
182 183 184 |
# File 'lib/ab_admin/config/base.rb', line 182 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
182 183 184 |
# File 'lib/ab_admin/config/base.rb', line 182 def @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_name ⇒ Object
191 192 193 |
# File 'lib/ab_admin/config/base.rb', line 191 def param_name [:as] || name end |