Class: Lolita::Menu::NestedTree::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/lolita-menu/nested_tree/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
	@klass = base_class					
	@options = options || {}
	initialize_options
	normalize_attributes
	validate
	extend_scope_classes
end

Instance Attribute Details

#build_methodObject (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

#klassObject (readonly)

Returns the value of attribute klass.



25
26
27
# File 'lib/lolita-menu/nested_tree/configuration.rb', line 25

def klass
  @klass
end

#optionsObject (readonly)

Returns the value of attribute options.



25
26
27
# File 'lib/lolita-menu/nested_tree/configuration.rb', line 25

def options
  @options
end

#scopeObject (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_classesObject



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_keysObject



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_reflectionsObject



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