module HyperResource::Modules::InternalAttributes::ClassMethods
Public Instance Methods
_hr_attributes()
click to toggle source
# File lib/hyper_resource/modules/internal_attributes.rb, line 32 def _hr_attributes # @private [ :root, :href, :auth, :headers, :namespace, :adapter, :token, :request, :response, :body, :attributes, :links, :objects, :loaded ] end
_hr_class_attribute(*names)
click to toggle source
Inheritable class attribute, kinda like in Rails.
# File lib/hyper_resource/modules/internal_attributes.rb, line 54 def _hr_class_attribute(*names) names.map(&:to_sym).each do |name| instance_eval <<-EOT def #{name}=(val) @#{name} = val end def #{name} return @#{name} if defined?(@#{name}) return superclass.#{name} if superclass.respond_to?(:#{name}) nil end EOT end end
_hr_class_attributes()
click to toggle source
# File lib/hyper_resource/modules/internal_attributes.rb, line 23 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 ] end
_hr_fallback_attribute(*names)
click to toggle source
Instance attributes which fall back to class attributes.
# File lib/hyper_resource/modules/internal_attributes.rb, line 70 def _hr_fallback_attribute(*names) names.map(&:to_sym).each do |name| class_eval <<-EOT def #{name}=(val) @#{name} = val end def #{name} return @#{name} if defined?(@#{name}) return self.class.#{name} if self.class.respond_to?(:#{name}) nil end EOT end end