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(relation, params) ⇒ Object
-
#initialize(name, options = {}, &block) ⇒ Scope
constructor
A new instance of Scope.
Constructor Details
#initialize(name, options = {}, &block) ⇒ Scope
Returns a new instance of Scope.
165 166 167 168 169 170 |
# File 'lib/ab_admin/config/base.rb', line 165 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.
163 164 165 |
# File 'lib/ab_admin/config/base.rb', line 163 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
163 164 165 |
# File 'lib/ab_admin/config/base.rb', line 163 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
163 164 165 |
# File 'lib/ab_admin/config/base.rb', line 163 def @options end |
Instance Method Details
#apply(relation, params) ⇒ Object
172 173 174 |
# File 'lib/ab_admin/config/base.rb', line 172 def apply(relation, params) data.is_a?(Proc) ? data.call(relation, params) : relation.public_send(name) end |