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



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

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



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

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

.receiver_optionsObject



28
29
30
31
32
# File 'lib/ccp/invokers/base.rb', line 28

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

Instance Method Details

#afterObject



45
46
47
48
# File 'lib/ccp/invokers/base.rb', line 45

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