Sha256: 190ff9eaa0e60b5b501a886dfdbfa23b45abcd294788f5adfe8861e1044603e3
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
module Panda class Resource < Base include Panda::Builders include Panda::Associations include Panda::CloudConnection def initialize(attributes={}) super(attributes) @attributes['cloud_id'] ||= Panda.cloud.id end class << self include Panda::Finders::FindMany include Panda::CloudConnection def cloud Panda.cloud end # delegate to the scope if the method exists def method_missing(method_symbol, *args, &block) scope = Panda::const_get("#{end_class_name}Scope").new(self) if scope.respond_to?(method_symbol) scope.send(method_symbol, *args, &block) else super end end end def cloud Panda.clouds[cloud_id] end def create raise "Can't create attribute. Already have an id=#{attributes['id']}" if attributes['id'] response = connection.post(object_url_map(self.class.many_path), attributes) load_response(response) ? (@changed_attributes = {}; true) : false end def create! create || errors.last.raise! end def reload perform_reload("cloud_id" => cloud_id) reset_associations self end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
panda-1.1.0 | lib/panda/resources/resource.rb |
faraday-panda-1.1.0 | lib/panda/resources/resource.rb |
panda-1.0.0 | lib/panda/resources/resource.rb |