Class: Admino::Query::Group
- Inherits:
-
Object
- Object
- Admino::Query::Group
- Defined in:
- lib/admino/query/group.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#query_i18n_key ⇒ Object
readonly
Returns the value of attribute query_i18n_key.
Instance Method Summary collapse
- #active_scope ⇒ Object
- #augment_scope(scope) ⇒ Object
- #available_scopes ⇒ Object
- #i18n_key ⇒ Object
-
#initialize(config, params, query_i18n_key = nil) ⇒ Group
constructor
A new instance of Group.
- #is_scope_active?(scope) ⇒ Boolean
- #param_name ⇒ Object
- #param_value ⇒ Object
Constructor Details
#initialize(config, params, query_i18n_key = nil) ⇒ Group
Returns a new instance of Group.
11 12 13 14 15 |
# File 'lib/admino/query/group.rb', line 11 def initialize(config, params, query_i18n_key = nil) @config = config @params = ActiveSupport::HashWithIndifferentAccess.new(params) @query_i18n_key = query_i18n_key end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/admino/query/group.rb', line 8 def config @config end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
7 8 9 |
# File 'lib/admino/query/group.rb', line 7 def params @params end |
#query_i18n_key ⇒ Object (readonly)
Returns the value of attribute query_i18n_key.
9 10 11 |
# File 'lib/admino/query/group.rb', line 9 def query_i18n_key @query_i18n_key end |
Instance Method Details
#active_scope ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/admino/query/group.rb', line 25 def active_scope if param_value && available_scopes.include?(param_value.to_sym) param_value.to_sym else nil end end |
#augment_scope(scope) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/admino/query/group.rb', line 17 def augment_scope(scope) if active_scope scope.send(active_scope) else scope end end |
#available_scopes ⇒ Object
45 46 47 |
# File 'lib/admino/query/group.rb', line 45 def available_scopes [nil] + config.scopes end |
#i18n_key ⇒ Object
49 50 51 |
# File 'lib/admino/query/group.rb', line 49 def i18n_key config.name end |
#is_scope_active?(scope) ⇒ Boolean
33 34 35 |
# File 'lib/admino/query/group.rb', line 33 def is_scope_active?(scope) active_scope == scope end |
#param_name ⇒ Object
41 42 43 |
# File 'lib/admino/query/group.rb', line 41 def param_name config.name end |
#param_value ⇒ Object
37 38 39 |
# File 'lib/admino/query/group.rb', line 37 def param_value params.fetch(param_name, nil) end |