Class: SearchCop::Reflection
- Inherits:
-
Object
- Object
- SearchCop::Reflection
- Defined in:
- lib/search_cop/search_scope.rb
Instance Attribute Summary collapse
-
#aliases ⇒ Object
Returns the value of attribute aliases.
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#generators ⇒ Object
Returns the value of attribute generators.
-
#options ⇒ Object
Returns the value of attribute options.
-
#scope ⇒ Object
Returns the value of attribute scope.
Instance Method Summary collapse
- #default_attributes ⇒ Object
-
#initialize ⇒ Reflection
constructor
A new instance of Reflection.
Constructor Details
#initialize ⇒ Reflection
Returns a new instance of Reflection.
5 6 7 8 9 10 |
# File 'lib/search_cop/search_scope.rb', line 5 def initialize self.attributes = {} self. = {} self.aliases = {} self.generators = {} end |
Instance Attribute Details
#aliases ⇒ Object
Returns the value of attribute aliases.
3 4 5 |
# File 'lib/search_cop/search_scope.rb', line 3 def aliases @aliases end |
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/search_cop/search_scope.rb', line 3 def attributes @attributes end |
#generators ⇒ Object
Returns the value of attribute generators.
3 4 5 |
# File 'lib/search_cop/search_scope.rb', line 3 def generators @generators end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/search_cop/search_scope.rb', line 3 def @options end |
#scope ⇒ Object
Returns the value of attribute scope.
3 4 5 |
# File 'lib/search_cop/search_scope.rb', line 3 def scope @scope end |
Instance Method Details
#default_attributes ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/search_cop/search_scope.rb', line 12 def default_attributes keys = .select { |_key, value| value[:default] == true }.keys keys = attributes.keys.reject { |key| [key] && [key][:default] == false } if keys.empty? keys = keys.to_set attributes.select { |key, _value| keys.include? key } end |