Class: Tessa::AssetChange

Inherits:
Object
  • Object
show all
Defined in:
lib/tessa/asset_change.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ AssetChange

Returns a new instance of AssetChange.



8
9
10
11
12
13
14
15
16
# File 'lib/tessa/asset_change.rb', line 8

def initialize(args={})
  case args
  when Array
    id, attributes = args
    super attributes.merge(id: id)
  else
    super
  end
end

Instance Method Details

#add?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/tessa/asset_change.rb', line 35

def add?
  action == 'add'
end

#applyObject



18
19
20
21
22
23
24
# File 'lib/tessa/asset_change.rb', line 18

def apply
  if add?
    asset.complete!
  elsif remove?
    asset.delete!
  end
end

#eql?(b) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
# File 'lib/tessa/asset_change.rb', line 30

def eql?(b)
  self.class == b.class &&
    self.hash == b.hash
end

#hashObject



26
27
28
# File 'lib/tessa/asset_change.rb', line 26

def hash
  [id, action].hash
end

#remove?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/tessa/asset_change.rb', line 39

def remove?
  action == 'remove'
end