Class: GoogleContacts::Proxies::Tag

Inherits:
BlankSlate
  • Object
show all
Defined in:
lib/google_contacts/proxies/tag.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent, options) ⇒ Tag

Returns a new instance of Tag.



4
5
6
7
8
9
# File 'lib/google_contacts/proxies/tag.rb', line 4

def initialize(parent, options)
  @parent = parent
  @tag    = options[:tag]

  reinitialize
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &blk) ⇒ Object (private)



37
38
39
40
41
42
43
# File 'lib/google_contacts/proxies/tag.rb', line 37

def method_missing(sym, *args, &blk)
  if @new.respond_to?(sym)
    @new.send(sym, *args, &blk)
  else
    super
  end
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/google_contacts/proxies/tag.rb', line 16

def changed?
  @current != @new
end

#reinitializeObject



11
12
13
14
# File 'lib/google_contacts/proxies/tag.rb', line 11

def reinitialize
  @current = node.try(:content)
  @new     = @current ? @current.dup : nil
end

#replace(content) ⇒ Object



20
21
22
# File 'lib/google_contacts/proxies/tag.rb', line 20

def replace(content)
  @new = content.to_s
end

#synchronizeObject



24
25
26
# File 'lib/google_contacts/proxies/tag.rb', line 24

def synchronize
  (node || insert_node).content = @new
end