Sha256: f5d34073165f04faec64bcac91a8e1a548ac64ba2e3582094eed9bde2782a51a

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

apimodule OAuthActiveResource
  # see has_many in Resource
  class Collection < Set
    def initialize(connection, resource, collection_uri)        
      super()
      @connection = connection
      @collection_uri = collection_uri
      @resource = resource
      reload
    end
   
    def to_json
      return "[ #{self.map { |obj| obj.to_json }.join(',')} ]"
    end
    
    def to_xml
      raise "NotImplemented"
    end
    
    def save
      @connection.put("#{@resource.class.site}#{@collection_uri}",self.to_json,{ 'Accept'=>'application/json', 'Content-Type' => 'application/json' })
    end
    
    def reload
      self.replace(@resource.find(:all, :from => @collection_uri))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jwagener-oauth-active-resource-0.1.0 lib/oauth_active_resource/collection.rb