Module: URL::Service::AcceptsEndpoint

Included in:
URL::Service, Endpoint
Defined in:
lib/url/accepts_endpoint.rb

Instance Method Summary collapse

Instance Method Details

#eigenclassObject

allows access to the eigenclass



34
35
36
# File 'lib/url/accepts_endpoint.rb', line 34

def eigenclass
  class << self; self; end
end

#endpoint(arg, &blk) ⇒ Object

creates the endpoint for which ever object it’s imported into



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/url/accepts_endpoint.rb', line 6

def endpoint arg, &blk
  endpoint = if arg.is_a?(Hash)
    f = arg.first
    name = f.shift
    f.shift
  else
    name = arg
  end

  eigenclass.send :attr_reader, "#{name}_endpoint"
  instance_eval "    def \#{name} params=nil, args={}\n      if params.nil?\n        @\#{name}_endpoint\n      else\n        @\#{name}_endpoint.find(params,args)\n      end\n    end\n  RUBY\n\n  builder = EndpointBuilder.new(@base_url,endpoint,&blk)\n  e = builder._endpoint\n  \n  e.inflate_into ||= @inflate_into if @inflate_into\n  instance_variable_set \"@\#{name}_endpoint\",e\nend\n", __FILE__, __LINE__