Class: RubyQL

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, json = false) ⇒ RubyQL

Returns a new instance of RubyQL.



4
5
6
7
8
9
10
# File 'lib/rubyql.rb', line 4

def initialize(params, json = false)
  if json
    @params = JSON.parse(params)
  else
    @params = params
  end
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



2
3
4
# File 'lib/rubyql.rb', line 2

def params
  @params
end

Instance Method Details

#executeObject



12
13
14
15
16
# File 'lib/rubyql.rb', line 12

def execute
  query.select do |key, value|
    response_attr.key? key
  end.merge query_params
end

#queryObject



30
# File 'lib/rubyql.rb', line 30

def query; end

#query_paramsObject



18
19
20
21
22
# File 'lib/rubyql.rb', line 18

def query_params
  @params.reject do |key, value|
    value == '' || value.nil?
  end
end

#response_attrObject



24
25
26
27
28
# File 'lib/rubyql.rb', line 24

def response_attr
  @params.select do |key, value|
    value == '' || value.nil?
  end
end