Class: RubyQL
- Inherits:
-
Object
- Object
- RubyQL
- Defined in:
- lib/rubyql.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(params) ⇒ RubyQL
constructor
A new instance of RubyQL.
- #query ⇒ Object
- #query_params ⇒ Object
- #response_attr ⇒ Object
Constructor Details
#initialize(params) ⇒ RubyQL
Returns a new instance of RubyQL.
6 7 8 9 10 11 12 13 14 |
# File 'lib/rubyql.rb', line 6 def initialize(params) if params.is_a?(JSON) @params = JSON.parse(params) elsif params.is_a?(Hash) @params = params else raise end end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
4 5 6 |
# File 'lib/rubyql.rb', line 4 def params @params end |
Instance Method Details
#execute ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rubyql.rb', line 16 def execute return {} if query.nil? query.select do |key, value| response_attr.key? key end.merge query_params end |
#query ⇒ Object
35 |
# File 'lib/rubyql.rb', line 35 def query; end |
#query_params ⇒ Object
23 24 25 26 27 |
# File 'lib/rubyql.rb', line 23 def query_params @params.reject do |key, value| value == '' || value.nil? end end |
#response_attr ⇒ Object
29 30 31 32 33 |
# File 'lib/rubyql.rb', line 29 def response_attr @params.select do |key, value| value == '' || value.nil? end end |