Class: RestEasy::Resource::ModelProxy

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

Overview

── Simple wrappers for instance state ──────────────────────────────

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ ModelProxy

Returns a new instance of ModelProxy.



78
79
80
81
82
83
# File 'lib/rest_easy/resource.rb', line 78

def initialize(attributes)
  @attributes = attributes
  attributes.each_key do |attr_name|
    define_singleton_method(attr_name) { @attributes[attr_name] }
  end
end

Instance Method Details

#attributesObject



85
86
87
# File 'lib/rest_easy/resource.rb', line 85

def attributes
  @attributes
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:



89
90
91
# File 'lib/rest_easy/resource.rb', line 89

def respond_to_missing?(method_name, include_private = false)
  @attributes.key?(method_name.to_sym) || super
end