summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/nasty.rb1
-rw-r--r--lib/nasty/binding_behaviour.rb7
-rw-r--r--spec/unit/binding_spec.rb16
3 files changed, 24 insertions, 0 deletions
diff --git a/lib/nasty.rb b/lib/nasty.rb
index 35b89ea..f73cdee 100644
--- a/lib/nasty.rb
+++ b/lib/nasty.rb
@@ -1,4 +1,5 @@
require "nasty/background_job"
+require "nasty/binding_behaviour"
require "nasty/command"
require "nasty/composite_command"
require "nasty/kernel"
diff --git a/lib/nasty/binding_behaviour.rb b/lib/nasty/binding_behaviour.rb
new file mode 100644
index 0000000..d043be0
--- /dev/null
+++ b/lib/nasty/binding_behaviour.rb
@@ -0,0 +1,7 @@
+module Nasty
+ module BindingBehaviour
+ def get_binder
+ binding
+ end
+ end
+end
diff --git a/spec/unit/binding_spec.rb b/spec/unit/binding_spec.rb
new file mode 100644
index 0000000..5b51d08
--- /dev/null
+++ b/spec/unit/binding_spec.rb
@@ -0,0 +1,16 @@
+require "spec_helper"
+
+module Nasty
+ describe BindingBehaviour do
+ it "exposes an objects private binding" do
+ item = Object.new
+ item.instance_eval do
+ @message = "secret"
+ end
+ item.extend(Nasty::BindingBehaviour)
+ binding = item.get_binder
+ result = ERB.new("<%= @message %>").result(binding)
+ result.should == "secret"
+ end
+ end
+end