Class: GoogleContacts::Wrapper::CollectionProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/google_contacts/wrapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(wrapper, klass) ⇒ CollectionProxy

Returns a new instance of CollectionProxy.



118
119
120
121
122
# File 'lib/google_contacts/wrapper.rb', line 118

def initialize(wrapper, klass)
  @wrapper    = wrapper
  @klass      = klass
  @collection = klass.name.demodulize.pluralize.underscore
end

Instance Method Details

#build(attributes = {}) ⇒ Object



131
132
133
134
135
# File 'lib/google_contacts/wrapper.rb', line 131

def build(attributes = {})
  @klass.new(@wrapper).tap do |instance|
    instance.attributes = attributes
  end
end

#find(what, options = {}) ⇒ Object

:what - all, ID, whatever, currently unused



125
126
127
128
129
# File 'lib/google_contacts/wrapper.rb', line 125

def find(what, options = {})
  @wrapper.find(@collection, options) do |entry|
    @klass.new(@wrapper, entry)
  end
end