Class: Cardiac::BaseReflection
- Inherits:
-
Object
- Object
- Cardiac::BaseReflection
- Defined in:
- lib/cardiac/reflections.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#http_verb ⇒ Object
(also: #http_verb?, #http_method)
readonly
Returns the value of attribute http_verb.
-
#macro ⇒ Object
readonly
Returns the value of attribute macro.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(resource_or_uri, http_verb = nil) ⇒ BaseReflection
constructor
A new instance of BaseReflection.
- #to_reflection ⇒ Object
- #to_uri ⇒ Object
- #to_url ⇒ Object
Constructor Details
#initialize(resource_or_uri, http_verb = nil) ⇒ BaseReflection
Returns a new instance of BaseReflection.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cardiac/reflections.rb', line 15 def initialize(resource_or_uri, http_verb=nil) @macro, @http_verb = self.class.build_macro, http_verb resource_or_uri.to_resource if resource_or_uri.respond_to?(:to_resource) case resource_or_uri when Cardiac::Resource @http_verb ||= resource_or_uri.method_value @uri = resource_or_uri.to_uri = resource_or_uri.send(:build_client_options, @http_verb) when URI @uri = resource_or_uri.dup = {} else @uri = resource_or_uri.to_uri if resource_or_uri.respond_to?(:to_uri) @http_verb ||= resource_or_uri.http_verb if resource_or_uri.respond_to?(:http_verb) ||= resource_or_uri. if resource_or_uri.respond_to?(:options) end = .dup .symbolize_keys! [:method] = @http_verb end |
Instance Attribute Details
#http_verb ⇒ Object (readonly) Also known as: http_verb?, http_method
Returns the value of attribute http_verb.
10 11 12 |
# File 'lib/cardiac/reflections.rb', line 10 def http_verb @http_verb end |
#macro ⇒ Object (readonly)
Returns the value of attribute macro.
10 11 12 |
# File 'lib/cardiac/reflections.rb', line 10 def macro @macro end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/cardiac/reflections.rb', line 10 def end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
10 11 12 |
# File 'lib/cardiac/reflections.rb', line 10 def uri @uri end |
Instance Method Details
#to_reflection ⇒ Object
46 47 48 |
# File 'lib/cardiac/reflections.rb', line 46 def to_reflection self end |
#to_uri ⇒ Object
38 39 40 |
# File 'lib/cardiac/reflections.rb', line 38 def to_uri @uri.dup end |
#to_url ⇒ Object
42 43 44 |
# File 'lib/cardiac/reflections.rb', line 42 def to_url @uri.to_s end |