Class: CloneKit::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/clone_kit/specification.rb

Constant Summary collapse

EMPTY_EMITTER =
Emitters::Empty.new
NO_OP_CLONER =
Cloners::NoOp.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, &block) ⇒ Specification



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/clone_kit/specification.rb', line 19

def initialize(model, &block)
  self.model = model
  self.emitter = EMPTY_EMITTER
  self.cloner = NO_OP_CLONER
  self.dependencies = []
  self.after_operation_block = -> (_op) {}

  validate!

  model.instance_exec(self, &block)

  CloneKit.add_specification(self)
end

Instance Attribute Details

#after_operation_blockObject

Returns the value of attribute after_operation_block.



10
11
12
# File 'lib/clone_kit/specification.rb', line 10

def after_operation_block
  @after_operation_block
end

#clonerObject

Returns the value of attribute cloner.



10
11
12
# File 'lib/clone_kit/specification.rb', line 10

def cloner
  @cloner
end

#dependenciesObject

Returns the value of attribute dependencies.



10
11
12
# File 'lib/clone_kit/specification.rb', line 10

def dependencies
  @dependencies
end

#emitterObject

Returns the value of attribute emitter.



10
11
12
# File 'lib/clone_kit/specification.rb', line 10

def emitter
  @emitter
end

#modelObject

Returns the value of attribute model.



10
11
12
# File 'lib/clone_kit/specification.rb', line 10

def model
  @model
end

Instance Method Details

#after_operation(&block) ⇒ Object



33
34
35
# File 'lib/clone_kit/specification.rb', line 33

def after_operation(&block)
  self.after_operation_block = block
end