Permalink
Browse files

Provide a declarative way of scoping on other exposed objects

  • Loading branch information...
1 parent 296ce00 commit 8cd46c553bed609ec7f2493ba5d49980f2ac313f @spartan-developer committed Apr 20, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/decent_exposure.rb
View
8 lib/decent_exposure.rb
@@ -16,15 +16,19 @@ def default_exposure(&block)
_default_exposure
end
- def expose(name, &block)
+ def expose(name, options = {}, &block)
closured_exposure = default_exposure
define_method name do
@_resources ||= {}
@_resources.fetch(name) do
@_resources[name] = if block_given?
instance_eval(&block)
else
- instance_exec(name, &closured_exposure)
+ if options[:through]
+ instance_eval { send(options[:through]).send(name) }
+ else
+ instance_exec(name, options, &closured_exposure)
+ end
end
end
end

0 comments on commit 8cd46c5

Please sign in to comment.