proxy_party 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -84,7 +84,14 @@ h2. Usage
84
84
  it "proxies speak accessor methods on mic" do
85
85
  subject = Party::Subject.new 'kristian'
86
86
  subject.mic = Mic.new 'hello'
87
- subject.proxy_accessors_for :mic, :speak
87
+
88
+ # multi
89
+ subject.proxy_accessors_for :mic, :speak, :miau
90
+
91
+ # single
92
+ subject.proxy_accessor_for :mic, :speak
93
+ subject.proxy_accessor_for :mic => :speak
94
+
88
95
  subject.speak = 'do it!'
89
96
  subject.speak.should == 'do it!'
90
97
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -104,6 +104,12 @@ module Party
104
104
  }
105
105
  end
106
106
 
107
+ def proxy_accessor_for obj, method = nil
108
+ method ||= obj[1] if obj.kind_of?(Hash)
109
+ raise ArgumentError, "Takes only a single accessor to proxy" if method.kind_of? Array
110
+ proxy_accessor_for obj, [method].flatten
111
+ end
112
+
107
113
  rename_methods.each_pair do |meth, new_meth|
108
114
  if check
109
115
  raise ArgumentError, "No such object to proxy #{obj}" if !self.respond_to?(obj)
@@ -195,6 +201,12 @@ module Party
195
201
  end
196
202
  end
197
203
 
204
+ def instance_proxy_accessor_for obj, method = nil
205
+ method ||= obj[1] if obj.kind_of?(Hash)
206
+ raise ArgumentError, "Takes only a single accessor to proxy" if method.kind_of? Array
207
+ instance_proxy_accessors_for obj, [method].flatten
208
+ end
209
+
198
210
  def named_proxies hash
199
211
  raise ArgumentError, "Argument must be a hash" if !hash.kind_of? Hash
200
212
  self.class.send :include, Party::Proxy
@@ -300,6 +312,12 @@ module Party
300
312
  end
301
313
  end
302
314
 
315
+ def proxy_accessor_for obj, method = nil
316
+ method ||= obj[1] if obj.kind_of?(Hash)
317
+ raise ArgumentError, "Takes only a single accessor to proxy" if method.kind_of? Array
318
+ proxy_accessors_for obj, [method].flatten
319
+ end
320
+
303
321
  protected
304
322
 
305
323
  def create_in_factory name
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{proxy_party}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2011-02-21}
11
+ s.authors = [%q{Kristian Mandrup}]
12
+ s.date = %q{2011-05-11}
13
13
  s.description = %q{Method missing proxy pattern}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -30,8 +30,8 @@ Gem::Specification.new do |s|
30
30
  "spec/spec_helper.rb"
31
31
  ]
32
32
  s.homepage = %q{http://github.com/kristianmandrup/proxy_party}
33
- s.require_paths = ["lib"]
34
- s.rubygems_version = %q{1.5.2}
33
+ s.require_paths = [%q{lib}]
34
+ s.rubygems_version = %q{1.8.0}
35
35
  s.summary = %q{Add proxy functionality the fun way}
36
36
  s.test_files = [
37
37
  "spec/proxy_party_complex_spec.rb",
@@ -109,7 +109,9 @@ describe Party::Proxy do
109
109
  it "proxies uses class level proxy factory with factory method" do
110
110
  subject = Party::Subject.new 'kristian'
111
111
  subject.add_proxy_factory :mic => [Mic, :create_empty]
112
- subject.instance_proxy_accessors_for :mic, :speak, :yawn
112
+ subject.instance_proxy_accessors_for :mic, :speak
113
+ subject.instance_proxy_accessor_for :mic, :yawn
114
+ subject.instance_proxy_accessor_for :mic => :yawn
113
115
  subject.speak = 'blip'
114
116
  subject.speak.should == 'blip'
115
117
  subject.yawn.should == 'miau'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxy_party
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-02-21 00:00:00.000000000 +01:00
13
- default_executable:
12
+ date: 2011-05-11 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: sugar-high
17
- requirement: &2157117440 !ruby/object:Gem::Requirement
16
+ requirement: &2153933580 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ! '>='
@@ -22,10 +21,10 @@ dependencies:
22
21
  version: 0.3.5
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *2157117440
24
+ version_requirements: *2153933580
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: rspec
28
- requirement: &2157116940 !ruby/object:Gem::Requirement
27
+ requirement: &2153932980 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ! '>='
@@ -33,7 +32,7 @@ dependencies:
33
32
  version: 2.4.0
34
33
  type: :development
35
34
  prerelease: false
36
- version_requirements: *2157116940
35
+ version_requirements: *2153932980
37
36
  description: Method missing proxy pattern
38
37
  email: kmandrup@gmail.com
39
38
  executables: []
@@ -53,7 +52,6 @@ files:
53
52
  - spec/proxy_party_complex_spec.rb
54
53
  - spec/proxy_party_spec.rb
55
54
  - spec/spec_helper.rb
56
- has_rdoc: true
57
55
  homepage: http://github.com/kristianmandrup/proxy_party
58
56
  licenses: []
59
57
  post_install_message:
@@ -74,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
72
  version: '0'
75
73
  requirements: []
76
74
  rubyforge_project:
77
- rubygems_version: 1.5.2
75
+ rubygems_version: 1.8.0
78
76
  signing_key:
79
77
  specification_version: 3
80
78
  summary: Add proxy functionality the fun way