simple-decorator 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/simple_decorator.rb +12 -4
  2. metadata +3 -3
@@ -1,12 +1,19 @@
1
+ require 'delegate'
2
+
1
3
  # Author:: Gabriel Dehan (gabriel-dehan)
2
4
  # License:: WTFPL (http://sam.zoy.org/wtfpl/COPYING)
3
5
  #
4
6
  # Allows you to give true decorator behavior to your classes.
5
- class SimpleDecorator < BasicObject
7
+ class SimpleDecorator < Delegator
8
+ # We must undefine those methods, for they will be sent to the underlying
9
+ # object
6
10
  undef_method :==
11
+ undef_method :class
12
+ undef_method :instance_of?
7
13
 
8
14
  # Stores the decorated object
9
15
  def initialize(component)
16
+ super
10
17
  @component = component
11
18
  end
12
19
 
@@ -14,8 +21,9 @@ class SimpleDecorator < BasicObject
14
21
  def decorated
15
22
  @component
16
23
  end
17
- alias :source :decorate
24
+ alias :source :decorated
18
25
 
19
- def send(s, *a); __send__(s, *a) end
20
- def method_missing(n, *a, &b); @component.send(n, *a, &b) end
26
+ def __setobj__(o); @component = o end
27
+ def __getobj__; @component end
28
+ def send(s, *a); __send__(s, *a) end
21
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-decorator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,14 +11,14 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-07-09 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: Implements true decorators in Ruby
14
+ description: Implements true and fully transparent decorators in Ruby
15
15
  email: dehan.gabriel@gmail.com
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - lib/simple_decorator.rb
21
- homepage: http://rubygems.org/gems/simple-decorator
21
+ homepage: https://github.com/gabriel-dehan/SimpleDecorator
22
22
  licenses: []
23
23
  post_install_message:
24
24
  rdoc_options: []