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.



6
7
8
9
10
# File 'lib/search_cop/search_scope.rb', line 6

def initialize
  self.attributes = {}
  self.options = {}
  self.aliases = {}
end

Instance Attribute Details

#aliasesObject

Returns the value of attribute aliases.



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

def aliases
  @aliases
end

#attributesObject

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

#scopeObject

Returns the value of attribute scope.



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

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