Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use #define_method in place of #instance_exec on a stored block.

  • Loading branch information...
commit f9d8fec869a92ed6d3f217bdcd97d6f9cc4ee6ba 1 parent 58c16b1
@jneen jneen authored
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/imperator/command.rb
View
12 lib/imperator/command.rb
@@ -15,7 +15,7 @@ class << self
end
def self.action(&block)
- @perform_block = block
+ define_method(:raw_perform, &block)
end
alias_method :params, :attributes
@@ -61,11 +61,13 @@ def perform!
self.perform
end
+ # @abstract
+ def raw_perform
+ raise "You need to define the perform block for #{self.class.name}"
+ end
+
def perform
- raise "You need to define the perform block for #{self.class.name}" unless self.class.perform_block
- run_callbacks :perform do
- self.instance_exec(&self.class.perform_block)
- end
+ run_callbacks(:perform) { raw_perform }
end
def method_missing(method, *args)
Please sign in to comment.
Something went wrong with that request. Please try again.