Class: URL::Service::Endpoint
- Inherits:
-
Object
- Object
- URL::Service::Endpoint
- Includes:
- AcceptsEndpoint
- Defined in:
- lib/url/endpoint.rb
Defined Under Namespace
Classes: EndpointNotResponding, RequiredParameter
Constant Summary collapse
- BUILT_IN_MAP =
Define the built in methods and their fetcher aliases
{ :get => %w{find}, :post => %w{create}, :put => %w{update}, :delete => %w{destroy} }.each do |method,aliases| class_eval <<-RUBY, __FILE__, __LINE__ def #{method} params = {}, opts = {} u = @url.dup u.params.merge! params u.#{method} opts end RUBY aliases.each do |al| class_eval <<-RUBY, __FILE__, __LINE__ def #{al} params={}, opts={} transform_response #{method}(params, opts) end RUBY end end.freeze
- BUILT_IN_METHODS =
BUILT_IN_MAP.collect do |k,v| v.collect{|vv| vv.to_sym}+[k.to_sym] end.flatten.freeze
Instance Attribute Summary collapse
-
#inflate_into ⇒ Object
Returns the value of attribute inflate_into.
Instance Method Summary collapse
-
#class_eval(*args, &blk) ⇒ Object
Expose class eval externally.
- #eigenclass ⇒ Object
-
#initialize(url) ⇒ Endpoint
constructor
A new instance of Endpoint.
- #inspect ⇒ Object
-
#method_inflate_into ⇒ Object
Storage for what each endpoint should inflate into.
Methods included from AcceptsEndpoint
Constructor Details
#initialize(url) ⇒ Endpoint
Returns a new instance of Endpoint.
40 41 42 |
# File 'lib/url/endpoint.rb', line 40 def initialize url @base_url = @url = url end |
Instance Attribute Details
#inflate_into ⇒ Object
Returns the value of attribute inflate_into.
4 5 6 |
# File 'lib/url/endpoint.rb', line 4 def inflate_into @inflate_into end |
Instance Method Details
#class_eval(*args, &blk) ⇒ Object
Expose class eval externally
45 46 47 |
# File 'lib/url/endpoint.rb', line 45 def class_eval *args,&blk eigenclass.class_eval *args,&blk end |
#eigenclass ⇒ Object
49 50 51 |
# File 'lib/url/endpoint.rb', line 49 def eigenclass class << self; self; end end |
#inspect ⇒ Object
53 54 55 |
# File 'lib/url/endpoint.rb', line 53 def inspect %Q{#<#{self.class} #{@url.to_s}>} end |
#method_inflate_into ⇒ Object
Storage for what each endpoint should inflate into
8 9 10 |
# File 'lib/url/endpoint.rb', line 8 def method_inflate_into @method_inflate_into ||= {} end |