Permalink
Browse files

Find constants correctly

  • Loading branch information...
1 parent 2539f8b commit 770aa39ef90b22bde66bd5ad2d752e0d5d906875 @joshuaclayton committed Jun 11, 2012
Showing with 8 additions and 4 deletions.
  1. +2 −2 README.md
  2. +4 −0 lib/basic_decorator/decorator.rb
  3. +2 −2 spec/lib/basic_decorator/decorator_spec.rb
View
@@ -67,7 +67,7 @@ Fairly straightforward. Let's write up decorators for `Cream` and `Sugar`.
```ruby
class Cream < BasicDecorator::Decorator
def cost
- @component.cost + ::Money.new(75, 'USD')
+ @component.cost + Money.new(75, 'USD')
end
def additional_ingredients
@@ -77,7 +77,7 @@ end
class Sugar < BasicDecorator::Decorator
def cost
- @component.cost + ::Money.new(25, 'USD')
+ @component.cost + Money.new(25, 'USD')
end
def additional_ingredients
@@ -13,5 +13,9 @@ def method_missing(name, *args, &block)
def send(symbol, *args)
__send__(symbol, *args)
end
+
+ def self.const_missing(name)
+ ::Object.const_get name
+ end
end
end
@@ -19,7 +19,7 @@ def additional_ingredients
class Cream < BasicDecorator::Decorator
def cost
- @component.cost + ::Money.new(75, 'USD')
+ @component.cost + Money.new(75, 'USD')
end
def additional_ingredients
@@ -29,7 +29,7 @@ def additional_ingredients
class Sugar < BasicDecorator::Decorator
def cost
- @component.cost + ::Money.new(25, 'USD')
+ @component.cost + Money.new(25, 'USD')
end
def additional_ingredients

0 comments on commit 770aa39

Please sign in to comment.