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

Returns a new instance of Specification.



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

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

  configure

  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.



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

def after_operation_block
  @after_operation_block
end

#clonerObject

Returns the value of attribute cloner.



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

def cloner
  @cloner
end

#dependenciesObject

Returns the value of attribute dependencies.



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

def dependencies
  @dependencies
end

#emitterObject

Returns the value of attribute emitter.



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

def emitter
  @emitter
end

#modelObject

Returns the value of attribute model.



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

def model
  @model
end

Instance Method Details

#after_operation(&block) ⇒ Object



35
36
37
# File 'lib/clone_kit/specification.rb', line 35

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