Class: Lolita::Menu::NestedTree::Configuration
- Inherits:
-
Object
- Object
- Lolita::Menu::NestedTree::Configuration
- Defined in:
- lib/lolita-menu/nested_tree/configuration.rb
Instance Attribute Summary collapse
-
#build_method ⇒ Object
readonly
Returns the value of attribute build_method.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#initialize(base_class, options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #scope_classes ⇒ Object
- #scope_key_for(klass) ⇒ Object
- #scope_keys ⇒ Object
- #scope_reflections ⇒ Object
Constructor Details
#initialize(base_class, options = {}) ⇒ Configuration
Returns a new instance of Configuration.
27 28 29 30 31 32 33 34 |
# File 'lib/lolita-menu/nested_tree/configuration.rb', line 27 def initialize(base_class, = {}) @klass = base_class @options = || {} normalize_attributes validate extend_scope_classes end |
Instance Attribute Details
#build_method ⇒ Object (readonly)
Returns the value of attribute build_method.
25 26 27 |
# File 'lib/lolita-menu/nested_tree/configuration.rb', line 25 def build_method @build_method end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
25 26 27 |
# File 'lib/lolita-menu/nested_tree/configuration.rb', line 25 def klass @klass end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
25 26 27 |
# File 'lib/lolita-menu/nested_tree/configuration.rb', line 25 def @options end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
25 26 27 |
# File 'lib/lolita-menu/nested_tree/configuration.rb', line 25 def scope @scope end |
Instance Method Details
#scope_classes ⇒ Object
48 49 50 51 52 |
# File 'lib/lolita-menu/nested_tree/configuration.rb', line 48 def scope_classes @scope.map do |scope| @klass.reflect_on_association(scope.to_sym).klass end end |
#scope_key_for(klass) ⇒ Object
42 43 44 45 46 |
# File 'lib/lolita-menu/nested_tree/configuration.rb', line 42 def scope_key_for(klass) scope_reflections.detect do |reflection| reflection.klass == klass end.foreign_key.to_sym end |
#scope_keys ⇒ Object
36 37 38 39 40 |
# File 'lib/lolita-menu/nested_tree/configuration.rb', line 36 def scope_keys @scope.map do |scope| @klass.reflect_on_association(scope.to_sym).foreign_key.to_sym end end |
#scope_reflections ⇒ Object
54 55 56 57 58 |
# File 'lib/lolita-menu/nested_tree/configuration.rb', line 54 def scope_reflections @scope.map do |scope| @klass.reflect_on_association(scope.to_sym) end end |