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.
164 165 166 167 168 |
# File 'lib/ab_admin/config/base.rb', line 164 def initialize(name, ={}, &block) @name = name @options = @data = block end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
162 163 164 |
# File 'lib/ab_admin/config/base.rb', line 162 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
162 163 164 |
# File 'lib/ab_admin/config/base.rb', line 162 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
162 163 164 |
# File 'lib/ab_admin/config/base.rb', line 162 def @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 |