Module: Facile::Api::ForwardMethods
- Includes:
- Forwardable
- Defined in:
- lib/facile/api/forward_methods.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.extended(base) ⇒ Object
7 8 9 10 |
# File 'lib/facile/api/forward_methods.rb', line 7 def self.extended(base) base.instance_variable_set(:@response, nil) base.instance_eval { attr_accessor :response } end |
Instance Method Details
#create_delegators(class_instance) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/facile/api/forward_methods.rb', line 20 def create_delegators(class_instance) if class_instance.response && class_instance.response.respond_to?(:keys) class_instance.response.keys.each do |key| class_instance.class.def_delegator :@response, key.to_sym class_instance.class.def_delegator :@response, "#{key}=".to_sym end end end |
#create_instance(body = nil) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/facile/api/forward_methods.rb', line 12 def create_instance(body = nil) class_instance = new class_instance.response = body create_delegators(class_instance) class_instance end |