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.
172 173 174 175 176 177 |
# File 'lib/ab_admin/config/base.rb', line 172 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.
170 171 172 |
# File 'lib/ab_admin/config/base.rb', line 170 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
170 171 172 |
# File 'lib/ab_admin/config/base.rb', line 170 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
170 171 172 |
# File 'lib/ab_admin/config/base.rb', line 170 def @options end |
Instance Method Details
#apply(relation, params) ⇒ Object
179 180 181 |
# File 'lib/ab_admin/config/base.rb', line 179 def apply(relation, params) data.is_a?(Proc) ? data.call(relation, params) : relation.public_send(name) end |