Class: Gutentag::ChangeState

Inherits:
Object
  • Object
show all
Defined in:
lib/gutentag/change_state.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(taggable) ⇒ ChangeState

Returns a new instance of ChangeState.



7
8
9
10
11
# File 'lib/gutentag/change_state.rb', line 7

def initialize(taggable)
  @taggable = taggable
  @existing = normalised taggable.tags.collect(&:name)
  @changes  = normalised taggable.tag_names
end

Instance Attribute Details

#normaliser=(value) ⇒ Object

Sets the attribute normaliser

Parameters:

  • value

    the value to set the attribute normaliser to.



5
6
7
# File 'lib/gutentag/change_state.rb', line 5

def normaliser=(value)
  @normaliser = value
end

#taggableObject (readonly)

Returns the value of attribute taggable.



4
5
6
# File 'lib/gutentag/change_state.rb', line 4

def taggable
  @taggable
end

Instance Method Details

#addedObject



13
14
15
# File 'lib/gutentag/change_state.rb', line 13

def added
  @added ||= changes - existing
end

#removedObject



17
18
19
# File 'lib/gutentag/change_state.rb', line 17

def removed
  @removed ||= existing - changes
end