lib/hyper_resource/modules/internal_attributes.rb in hyperresource-0.2.4 vs lib/hyper_resource/modules/internal_attributes.rb in hyperresource-0.9.0
- old
+ new
@@ -17,43 +17,31 @@
base._hr_fallback_attribute attr
end
end
module ClassMethods
-
- def _hr_class_attributes # @private
- [ :root, ## e.g. 'https://example.com/api/v1'
- :auth, ## e.g. {:basic => ['username', 'password']}
- :headers, ## e.g. {'Accept' => 'application/vnd.example+json'}
- :namespace, ## e.g. 'ExampleAPI', or the class ExampleAPI itself
- :adapter, ## subclass of HR::Adapter
- :faraday_options ## e.g. {:request => {:timeout => 30}}
- ]
+ # @private
+ def _hr_class_attributes
+ [ :root ]
end
- def _hr_attributes # @private
+ # @private
+ def _hr_attributes
[ :root,
:href,
- :auth,
- :headers,
- :namespace,
- :adapter,
- :faraday_options,
-
:request,
:response,
:body,
-
:attributes,
:links,
:objects,
-
:loaded
]
end
## Inheritable class attribute, kinda like in Rails.
+ # @private
def _hr_class_attribute(*names)
names.map(&:to_sym).each do |name|
instance_eval <<-EOT
def #{name}=(val)
@#{name} = val
@@ -66,9 +54,10 @@
EOT
end
end
## Instance attributes which fall back to class attributes.
+ # @private
def _hr_fallback_attribute(*names)
names.map(&:to_sym).each do |name|
class_eval <<-EOT
def #{name}=(val)
@#{name} = val