Class: BigDoor::Base

Inherits:
Object
  • Object
show all
Includes:
ClassMethods
Defined in:
lib/big-door/base.rb

Instance Method Summary collapse

Methods included from ClassMethods

app_key, included, #parse_out_classes, #perform_request, #remote_id, secret_key

Constructor Details

#initialize(*args) ⇒ Base

Returns a new instance of Base.



5
6
7
8
9
10
11
12
13
# File 'lib/big-door/base.rb', line 5

def initialize(*args)
	options = args.last
	ClassMethods.module_eval do
		instance_variable_set('@app_key', options[:app_key])
	end
	ClassMethods.module_eval do
		instance_variable_set('@secret_key', options[:secret_key])
	end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

def get_award_summary perform_get(‘award_summary’) end

def get_transaction_summary perform_get(‘transaction_summary’) end

def get_level_summary perform_get(‘level_summary’) end

def get_good_summary perform_get(‘good_summary’) end

def get_currency_type perform_get(‘currency_type’) end

def get_currency perform_get(‘currency’) end



39
40
41
42
43
# File 'lib/big-door/base.rb', line 39

def method_missing(name, *args)
	name, request_type, method_name = name.to_s.match(/(put|post|get|delete)_(.+)/).to_a
	super(name, args) if name.nil? or request_type.nil? or method_name.nil?
	perform_request request_type, method_name, args.first
end