Class: Rdmm::Queries::BaseQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/rdmm/queries/base_query.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ BaseQuery

Returns a new instance of BaseQuery.

Parameters:

  • options (Hash) (defaults to: {})


27
28
29
# File 'lib/rdmm/queries/base_query.rb', line 27

def initialize(options = {})
  @options = options
end

Class Attribute Details

.property_namesArray<Symbol>

Returns:

  • (Array<Symbol>)


13
14
15
# File 'lib/rdmm/queries/base_query.rb', line 13

def property_names
  @property_names ||= []
end

Class Method Details

.inherited(child_class) ⇒ Object

Note:

Override



8
9
10
# File 'lib/rdmm/queries/base_query.rb', line 8

def inherited(child_class)
  child_class.property_names = property_names.clone
end

.property(property_name) ⇒ Object

Parameters:

  • property_name (Symbol)


18
19
20
# File 'lib/rdmm/queries/base_query.rb', line 18

def property(property_name)
  property_names << property_name
end

Instance Method Details

#affiliate_idString

Returns:

  • (String)


32
33
34
# File 'lib/rdmm/queries/base_query.rb', line 32

def affiliate_id
  options[:affiliate_id]
end

#api_idString

Returns:

  • (String)


37
38
39
# File 'lib/rdmm/queries/base_query.rb', line 37

def api_id
  options[:api_id]
end

#to_hashHash

Returns:

  • (Hash)


42
43
44
45
46
47
48
49
# File 'lib/rdmm/queries/base_query.rb', line 42

def to_hash
  self.class.property_names.each_with_object({}) do |property_name, result|
    value = send(property_name)
    unless value.nil?
      result[property_name.to_s] = value
    end
  end
end