Class: Flickr::Reflection
Instance Attribute Summary
Attributes inherited from APIBase
Instance Method Summary collapse
-
#getMethodInfo(method_name) ⇒ Object
We don’t bother with caching because it’s not worth it for the reflection API.
- #getMethods ⇒ Object
- #missing_methods ⇒ Object
Methods inherited from APIBase
Constructor Details
This class inherits a constructor from Flickr::APIBase
Instance Method Details
#getMethodInfo(method_name) ⇒ Object
We don’t bother with caching because it’s not worth it for the reflection API.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/flickr/reflection.rb', line 51 def getMethodInfo(method_name) res = @flickr.call_method('flickr.reflection.getMethodInfo', 'method_name' => method_name) els = res.elements att = res.root.attributes desc = els['/method/description'] ? els['/method/description'].text : nil resp = els['/method/response'] ? els['/method/response'].text : nil expl = els['/method/explanation'] ? els['/method/explanation'].text : nil meth = Flickr::Method.new(att['name'],att['needslogin'].to_i==1, desc,resp,expl) els['/method/arguments'].each_element do |el| att = el.attributes arg = Flickr::MethodArgument.new(att['name'], att['optional'].to_i == 1,el.text) meth.arguments << arg end els['/method/errors'].each_element do |el| att = el.attributes err = XMLRPC::FaultException.new(att['code'].to_i, el.text) meth.errors << err end return meth end |
#getMethods ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/flickr/reflection.rb', line 79 def getMethods res = @flickr.call_method('flickr.reflection.getMethods') list = [] res.elements['/methods'].each_element do |el| list << el.text end return list end |
#missing_methods ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/flickr/reflection.rb', line 88 def missing_methods list = [] methods = self.getMethods methods.each do |mname| parts = mname.split('.') parts.shift call = parts.pop obj = @flickr parts.each do |part| if obj.respond_to?(part) obj = obj.method(part).call else obj = nil list << mname break end end list << mname if (obj && !obj.respond_to?(call)) end return list end |