Class: Snaps::Snapshot

Inherits:
Struct
  • Object
show all
Defined in:
lib/snaps/snapshot.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



2
3
4
# File 'lib/snaps/snapshot.rb', line 2

def options
  @options
end

#recordObject

Returns the value of attribute record

Returns:

  • (Object)

    the current value of record



2
3
4
# File 'lib/snaps/snapshot.rb', line 2

def record
  @record
end

Class Method Details

.create(record, options, &block) ⇒ Object



3
4
5
# File 'lib/snaps/snapshot.rb', line 3

def self.create(record, options, &block)
  new(record, options).create(&block)
end

Instance Method Details

#create {|copy| ... } ⇒ Object

Yields:

  • (copy)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/snaps/snapshot.rb', line 7

def create
  copy = record.dup
  yield(copy) if block_given?

  Tag.suppress do
    copy.save
  end

  copy.snaps_tag!(options[:tag]) if options[:tag]

  snapshot_components(copy)

  copy
end