Skip to content

Commit

Permalink
use #define_method in place of #instance_exec on a stored block.
Browse files Browse the repository at this point in the history
  • Loading branch information
jneen committed May 11, 2012
1 parent 58c16b1 commit f9d8fec
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/imperator/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class << self
end

def self.action(&block)
@perform_block = block
define_method(:raw_perform, &block)
end

alias_method :params, :attributes
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f9d8fec

Please sign in to comment.