Sha256: 02293f6aa9966de6726e921f7a262455fff8fd78779c5e2fff833138a1eb5418

Contents?: true

Size: 799 Bytes

Versions: 3

Compression:

Stored size: 799 Bytes

Contents

module ClassyResources
  module Sequel
    def load_shallow_collection(resource)
      class_for(resource).all
    end

    def load_nested_collection(resource, parent)
      load_parent_object(parent).send(resource)
    end

    def create_shallow_object(resource, object_params)
      class_for(resource).create(object_params)
    end

    def create_nested_object(resource, object_params, parent)
      c = class_for(resource).new(object_params)
      load_parent_object(parent).send(:"add_#{resource.to_s.singularize}", c)
    end

    def load_object(resource, id)
      class_for(resource).find(:id => id)
    end

    def update_object(object, params)
      object.update(params)
    end

    def destroy_object(object)
      object.destroy
    end
  end
end

include ClassyResources::Sequel

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
giraffesoft-classy_resources-0.1.1 lib/classy_resources/sequel.rb
giraffesoft-classy_resources-0.2.0 lib/classy_resources/sequel.rb
giraffesoft-classy_resources-0.2.1 lib/classy_resources/sequel.rb