Class: FlickRaw::Request
- Inherits:
-
Object
- Object
- FlickRaw::Request
- Defined in:
- lib/flickraw.rb
Direct Known Subclasses
Class Method Summary collapse
-
.build_request(req) ⇒ Object
:nodoc:.
-
.flickr_methods ⇒ Object
List of the flickr methods of this object.
-
.flickr_objects ⇒ Object
List of the flickr subobjects of this object.
-
.request_name ⇒ Object
Returns the prefix of the request corresponding to this class.
Instance Method Summary collapse
-
#initialize(flickr = nil) ⇒ Request
constructor
:nodoc:.
Constructor Details
#initialize(flickr = nil) ⇒ Request
:nodoc:
90 91 92 93 94 95 96 97 |
# File 'lib/flickraw.rb', line 90 def initialize(flickr = nil) # :nodoc: @flickr = flickr self.class.flickr_objects.each {|name| klass = self.class.const_get name.capitalize instance_variable_set "@#{name}", klass.new(@flickr) } end |
Class Method Details
.build_request(req) ⇒ Object
:nodoc:
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/flickraw.rb', line 99 def self.build_request(req) # :nodoc: method_nesting = req.split '.' raise "'#{@name}' : Method name mismatch" if method_nesting.shift != request_name.split('.').last if method_nesting.size > 1 name = method_nesting.first class_name = name.capitalize if const_defined?(class_name, false) klass = const_get(class_name) else klass = Class.new Request const_set(class_name, klass) attr_reader name flickr_objects << name end klass.build_request method_nesting.join('.') else req = method_nesting.first define_method(req) { |*args| class_req = self.class.request_name @flickr.call class_req + '.' + req, *args } flickr_methods << req end end |
.flickr_methods ⇒ Object
List of the flickr methods of this object
130 |
# File 'lib/flickraw.rb', line 130 def self.flickr_methods; @flickr_methods ||= [] end |
.flickr_objects ⇒ Object
List of the flickr subobjects of this object
127 |
# File 'lib/flickraw.rb', line 127 def self.flickr_objects; @flickr_objects ||= [] end |
.request_name ⇒ Object
Returns the prefix of the request corresponding to this class.
133 |
# File 'lib/flickraw.rb', line 133 def self.request_name; name.downcase.gsub(/::/, '.').sub(/[^\.]+\./, '') end |