lib/yuyi/roll.rb in yuyi-0.0.3 vs lib/yuyi/roll.rb in yuyi-0.0.6

- old
+ new

@@ -11,19 +11,21 @@ def self.file_name file_name = nil file_name ? @file_name = file_name : @file_name end def self.pre_install &block - Yuyi::Menu.add_pre_install block + Yuyi::Menu.add_pre_install self unless @pre_install + @pre_install ||= block end def self.install &block @install ||= block end def self.post_install &block - Yuyi::Menu.add_post_install block + Yuyi::Menu.add_post_install self unless @post_install + @post_install ||= block end def self.uninstall &block @uninstall ||= block end @@ -83,11 +85,11 @@ self.class.dependencies end # Run the roll # - def order + def install if installed? if options[:uninstall] Yuyi.say "🍣\s Uninstalling #{title}...", :color => 33 uninstall elsif upgrade? @@ -97,11 +99,19 @@ else Yuyi.say "🍣\s Installing #{title}...", :color => 32 install end end + alias_method :order, :install + alias_method :entree, :install + def pre_install; pre_install; end + alias_method :appetizers, :pre_install + + def post_install; post_install; end + alias_method :dessert, :pre_install + private def upgrade? Yuyi::Menu.upgrade? end @@ -124,11 +134,19 @@ Yuyi::Menu.find_roll roll end end end + def pre_install + instance_eval(&self.class.pre_install) + end + def install instance_eval(&self.class.install) + end + + def post_install + instance_eval(&self.class.post_install) end def uninstall instance_eval(&self.class.uninstall) end