Class: ActiveGraph::Core::Query::Parameters

Inherits:
Object
  • Object
show all
Defined in:
lib/active_graph/core/query.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash = nil) ⇒ Parameters

Returns a new instance of Parameters.



20
21
22
# File 'lib/active_graph/core/query.rb', line 20

def initialize(hash = nil)
  @parameters = (hash || {})
end

Instance Method Details

#add_param(key, value) ⇒ Object



32
33
34
35
36
# File 'lib/active_graph/core/query.rb', line 32

def add_param(key, value)
  free_param_key(key).tap do |k|
    @parameters[k.freeze] = value
  end
end

#add_params(params) ⇒ Object



42
43
44
45
46
# File 'lib/active_graph/core/query.rb', line 42

def add_params(params)
  params.map do |key, value|
    add_param(key, value)
  end
end

#copyObject



28
29
30
# File 'lib/active_graph/core/query.rb', line 28

def copy
  self.class.new(@parameters.dup)
end

#remove_param(key) ⇒ Object



38
39
40
# File 'lib/active_graph/core/query.rb', line 38

def remove_param(key)
  @parameters.delete(key.to_sym)
end

#to_hashObject



24
25
26
# File 'lib/active_graph/core/query.rb', line 24

def to_hash
  @parameters
end