Class: Cloned::Base

Inherits:
Object
  • Object
show all
Extended by:
DSL
Defined in:
lib/cloned/base.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes included from DSL

#associations

Instance Method Summary collapse

Methods included from DSL

association, nullify

Constructor Details

#initialize(target:, destination: nil, **options) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
# File 'lib/cloned/base.rb', line 8

def initialize(target:, destination: nil, **options)
  @target = target
  @destination = destination
  @options = options
end

Class Attribute Details

.strategyObject

Returns the value of attribute strategy.



46
47
48
# File 'lib/cloned/base.rb', line 46

def strategy
  @strategy
end

Instance Attribute Details

#copyObject (readonly)

Returns the value of attribute copy.



5
6
7
# File 'lib/cloned/base.rb', line 5

def copy
  @copy
end

#destinationObject (readonly)

Returns the value of attribute destination.



5
6
7
# File 'lib/cloned/base.rb', line 5

def destination
  @destination
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/cloned/base.rb', line 5

def options
  @options
end

#targetObject (readonly)

Returns the value of attribute target.



5
6
7
# File 'lib/cloned/base.rb', line 5

def target
  @target
end

Instance Method Details

#makeObject



14
15
16
17
18
19
20
21
# File 'lib/cloned/base.rb', line 14

def make
  if skip_transaction?
    make_or_fail!
  else
    ActiveRecord::Base.transaction { make_or_fail! }
  end
  copy
end

#valid?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/cloned/base.rb', line 23

def valid?
  target.presence
end