Sha256: b70e78e60a23d963a5e26f93f7614e2862a0a1db42835832f23a853ea21c0a96

Contents?: true

Size: 650 Bytes

Versions: 5

Compression:

Stored size: 650 Bytes

Contents

module Mashery
  class ApiObjectBase
    def self.create(fields = {})
      # XXX: only send fields that aren't read-only
      new(Mashery.client.call_remote(method('create'), fields))
    end

    def self.fetch(id)
      data = Mashery.client.call_remote(method('fetch'), id)
      data.nil?? nil : new(data)
    end

    def self.delete(id)
      Mashery.client.call_remote(method('delete'), id)
    end

    def self.method(basename)
      "#{name.split(/\:\:/).last.downcase}.#{basename}"
    end

    def initialize(data)
      # XXX: use setter methods
      data.each_pair {|k, v| instance_variable_set("@#{k}".to_sym, v)}
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mashery-0.1.1 lib/mashery/api_object_base.rb
mashery-0.1.0 lib/mashery/api_object_base.rb
mashery-0.0.11 lib/mashery/api_object_base.rb
mashery-0.0.10 lib/mashery/api_object_base.rb
mashery-0.0.9 lib/mashery/api_object_base.rb