Class: Ccp::Invokers::Base

Inherits:
Object
  • Object
show all
Includes:
Commands::Composite, Utils::Options
Defined in:
lib/ccp/invokers/base.rb

Direct Known Subclasses

Spec

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::Options

included

Methods included from Commands::Composite

#commands, #execute, included, #receiver=

Methods included from Commands::Core

included, #inspect

Constructor Details

#initialize(options = {}) ⇒ Base

Instance Methods



39
40
41
42
43
44
45
# File 'lib/ccp/invokers/base.rb', line 39

def initialize(options = {})
  self.receiver = options.delete(:receiver) || self.class.receiver.new
  receiver.parse!(self.class.receiver_options)
  receiver.parse!(options)
  receiver.data.default.merge!(self.class.builtins.options)
  receiver.data.default.merge!(self.class.default_options)
end

Class Method Details

.execute(options = {}, &block) ⇒ Object

Class Methods



23
24
25
26
27
28
# File 'lib/ccp/invokers/base.rb', line 23

def self.execute(options = {}, &block)
  cmd = new(options)
  cmd.instance_eval(&block) if block_given?
  cmd.receiver.execute(cmd)
  return cmd
end

.receiver_optionsObject



30
31
32
33
34
# File 'lib/ccp/invokers/base.rb', line 30

def self.receiver_options
  opts = fixtures.options
  opts[:fixture_keys] ||= builtins.options.keys.map{|i| "!#{i}"}
  return opts
end

Instance Method Details

#afterObject



47
48
49
50
# File 'lib/ccp/invokers/base.rb', line 47

def after
  receiver.show_profiles if data?(:profile)
  receiver.show_comments if data?(:comment)
end