lib/arli/actions/action.rb in arli-0.8.3 vs lib/arli/actions/action.rb in arli-0.9.0
- old
+ new
@@ -1,52 +1,26 @@
-require_relative '../output'
+require 'arli/helpers/output'
+require 'arli/helpers/inherited'
module Arli
module Actions
# Represents an abstract action related to the library
class Action
- include Arli::Output
+ include Arli::Helpers::Output
+ include Arli::Helpers::Inherited
+ attr_assignable :check_command, :check_pattern, :description
+
extend Forwardable
def_delegators :@library,
:exists?,
:path, :temp_path,
:dir, :temp_dir,
:libraries_home
class << self
def inherited(base)
-
- base.instance_eval do
- class << self
- attr_writer :check_command, :check_pattern, :description
-
- def action_name
- name.gsub(/.*::/, '').underscore.to_sym
- end
-
- def set_or_get(var_name, val = nil)
- var = "@#{var_name}".to_sym
- self.instance_variable_set(var, val) if val
- self.instance_variable_get(var)
- end
-
- def check_pattern(val = nil)
- set_or_get('check_pattern', val)
- end
-
- def check_command(val = nil)
- set_or_get('check_command', val)
- end
-
- def description(val = nil)
- set_or_get('description', val)
- end
- end
- end
-
- # Add to the list of actions
- ::Arli::Actions.actions[base.action_name] = base
+ ::Arli::Actions.actions[base.short_name] = base
end
end
attr_accessor :library, :config