Class: PivotalTracker::Proxy
- Inherits:
-
BasicObject
- Defined in:
- lib/pivotal-tracker/proxy.rb
Instance Method Summary
collapse
Constructor Details
#initialize(owner, target) ⇒ Proxy
Returns a new instance of Proxy.
8
9
10
11
12
|
# File 'lib/pivotal-tracker/proxy.rb', line 8
def initialize(owner, target)
@owner = owner
@target = target
@opts = nil
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
56
57
58
|
# File 'lib/pivotal-tracker/proxy.rb', line 56
def method_missing(method, *args, &block)
@target.send(method, *args, &block)
end
|
Instance Method Details
#<<(*objects) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/pivotal-tracker/proxy.rb', line 24
def <<(*objects)
objects.flatten.each do |object|
if obj = object.create
return obj
else
return object
end
end
end
|
#all(options = {}) ⇒ Object
14
15
16
|
# File 'lib/pivotal-tracker/proxy.rb', line 14
def all(options={})
proxy_found(options)
end
|
#create(args) ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/pivotal-tracker/proxy.rb', line 34
def create(args)
object = @target.new(args.merge({:owner => @owner}))
if obj = object.create
return obj
else
return object
end
end
|
#find(param, options = {}) ⇒ Object
18
19
20
21
22
|
# File 'lib/pivotal-tracker/proxy.rb', line 18
def find(param, options={})
return all(options) if param == :all
return @target.find(param, @owner.id) if @target.respond_to?("find")
return proxy_found(options).detect { |document| document.id == param }
end
|