Class: SearchCop::Reflection

Inherits:
Object
  • Object
show all
Defined in:
lib/search_cop/search_scope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReflection

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.options = {}
  self.aliases = {}
  self.generators = {}
end

Instance Attribute Details

#aliasesObject

Returns the value of attribute aliases.



3
4
5
# File 'lib/search_cop/search_scope.rb', line 3

def aliases
  @aliases
end

#attributesObject

Returns the value of attribute attributes.



3
4
5
# File 'lib/search_cop/search_scope.rb', line 3

def attributes
  @attributes
end

#generatorsObject

Returns the value of attribute generators.



3
4
5
# File 'lib/search_cop/search_scope.rb', line 3

def generators
  @generators
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/search_cop/search_scope.rb', line 3

def options
  @options
end

#scopeObject

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_attributesObject



12
13
14
15
16
17
18
# File 'lib/search_cop/search_scope.rb', line 12

def default_attributes
  keys = options.select { |_key, value| value[:default] == true }.keys
  keys = attributes.keys.reject { |key| options[key] && options[key][:default] == false } if keys.empty?
  keys = keys.to_set

  attributes.select { |key, _value| keys.include? key }
end