Class: GoogleContacts::Proxies::Tag

Inherits:
ActiveSupport::BasicObject
Defined in:
lib/google_contacts/proxies/tag.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent, options) ⇒ Tag

Returns a new instance of Tag.



7
8
9
10
11
12
# File 'lib/google_contacts/proxies/tag.rb', line 7

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)



40
41
42
43
44
45
46
# File 'lib/google_contacts/proxies/tag.rb', line 40

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)


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

def changed?
  @current != @new
end

#reinitializeObject



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

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

#replace(content) ⇒ Object



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

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

#synchronizeObject



27
28
29
# File 'lib/google_contacts/proxies/tag.rb', line 27

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