Class: Musashi::Resource

Inherits:
Object
  • Object
show all
Includes:
Musashi
Defined in:
lib/musashi.rb,
lib/musashi/resource.rb

Defined Under Namespace

Modules: Format, JSON

Constant Summary

Constants included from Musashi

VERSION

Instance Attribute Summary

Attributes included from Connection

#endpoint, #format

Instance Method Summary collapse

Methods included from Musashi::Retriever::DelegateHash

#[], #attrs, #fetch, #key?, #keys, #method_missing

Methods included from Musashi::Retriever::VisitorStrategist

#[], extend?, extend_object, #has_key?, #method_missing, #respond_to?

Methods included from Musashi::Retriever::Strategist

define, #define, define_by_behavior, define_by_name, extend_object, #follow?, #no_follow, retrievers_by_behavior, retrievers_by_behavior=, retrievers_by_name, retrievers_by_name=

Methods included from Musashi::Retriever::Base

#retrieve, #retrieved?

Methods included from Connection

#accept, #connection, #options

Methods included from Publisher

#attributes, marshall, marshalls, #method_missing, #post, #put, #update_attributes

Constructor Details

#initialize(url, options = {}) ⇒ Resource

Returns a new instance of Resource.

Raises:

  • (ArgumentError)


52
53
54
55
56
57
# File 'lib/musashi/resource.rb', line 52

def initialize(url,options={})
  raise ArgumentError.new('Undefined url') if url.nil? or url.empty?
  resource_type = Format.formats[ options[:format] || :json ]
  extend(resource_type) unless resource_type.nil?
  self.endpoint = url
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Musashi::Retriever::DelegateHash