Module: MongoHQClient::Commons
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
3
4
5
6
7
8
9
10
11
12
|
# File 'lib/mongohq-client/commons.rb', line 3
def method_missing(method, *args)
attribute = method.to_s
if (attribute.to_s.end_with? '?')
attribute = attribute.to_s[0..-2]
end
super.method_missing(method, *args) unless json_hash.has_key? attribute
return json_hash["#{attribute}"]
end
|
Instance Method Details
#initialize(params = {}) ⇒ Object
14
15
16
17
|
# File 'lib/mongohq-client/commons.rb', line 14
def initialize(params = {})
raise "Invalid json" unless params[:json].is_a? Hash
@params = params
end
|