Module: Flickr::Proxy
Overview
Flickr Proxy
This contains shared functionality for Flickr Proxy classes.
Any class that includes this should call super on initialize to pass in the XML and Flickr::Client instance, if they overide initialize.
All attributes from the Hpricto::Elem passed in to initialize will be grabbed and mapped to method calls, for example:
xml => #<Hpricot::Doc {emptyelem <foo id="3" foo="bar">}>
test = Myclass.new( xml, client )
test.id => "3"
test.foo => "bar"
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Class Method Summary collapse
-
.included(klass) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#id ⇒ Object
Return the id, instead of the object_id.
-
#initialize(xml, client) ⇒ Object
Create a new proxy class.
-
#method_missing(method, *args) ⇒ Object
This maps method calls to attributes.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
This maps method calls to attributes.
40 41 42 43 |
# File 'lib/simple-flickr/proxy.rb', line 40 def method_missing( method, *args ) # :nodoc: return @attributes[method.to_s] if @attributes.include?(method.to_s) super end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
18 19 20 |
# File 'lib/simple-flickr/proxy.rb', line 18 def attributes @attributes end |
Class Method Details
.included(klass) ⇒ Object
:nodoc:
64 65 66 |
# File 'lib/simple-flickr/proxy.rb', line 64 def self.included(klass) # :nodoc: klass.extend(ClassMethods) end |
Instance Method Details
#id ⇒ Object
Return the id, instead of the object_id
35 36 37 |
# File 'lib/simple-flickr/proxy.rb', line 35 def id # :nodoc: @attributes[ 'id' ] end |
#initialize(xml, client) ⇒ Object
Create a new proxy class. This needs an Hpricot::Elem of the XML returned from Flickr, from Flickr::Client#request.
Typically you don’t want to call this directly, and should be using the find
method of the class instead.
Parameters
- :xml<Hpricot::Elem>
-
XML from Flickr, in Hpricot form.
- :client<Flickr::Client>
-
A Flickr::Client to use for communication with flickr.
29 30 31 32 |
# File 'lib/simple-flickr/proxy.rb', line 29 def initialize( xml, client ) @attributes = xml.raw_attributes @client = client end |