Sha256: ec3ad8ae6a654d4840569f6e5da4200ca525d9434510997320163f090a26050f

Contents?: true

Size: 754 Bytes

Versions: 39

Compression:

Stored size: 754 Bytes

Contents

module Gris
  module CrudHelpers
    def create(type, options = {})
      instance = type.create! options[:from]
      present instance, with: options[:with]
    end

    def update(instance, options = {})
      instance.update_attributes! options[:from]
      present instance, with: options[:with]
    end

    def delete(instance, options = {})
      instance.destroy
      present instance, with: options[:with]
    end

    def permitted_params(options = {})
      options = { include_missing: false }.merge(options)
      process_datetime_params(params) if respond_to?(:process_datetime_params)
      declared(params, options)
    end

    # extend all endpoints to include this
    Grape::Endpoint.send :include, self if defined?(Grape)
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
gris-0.6.8 lib/gris/grape_extensions/crud_helpers.rb
gris-0.6.7 lib/gris/grape_extensions/crud_helpers.rb
gris-0.6.6 lib/gris/grape_extensions/crud_helpers.rb
gris-0.6.5 lib/gris/grape_extensions/crud_helpers.rb
gris-0.6.2 lib/gris/grape_extensions/crud_helpers.rb
gris-0.6.1 lib/gris/grape_extensions/crud_helpers.rb
gris-0.6.0 lib/gris/grape_extensions/crud_helpers.rb
gris-0.5.9 lib/gris/grape_extensions/crud_helpers.rb
gris-0.5.8 lib/gris/grape_extensions/crud_helpers.rb
gris-0.5.7 lib/gris/grape_extensions/crud_helpers.rb
gris-0.5.6 lib/gris/grape_extensions/crud_helpers.rb
gris-0.5.5 lib/gris/grape_extensions/crud_helpers.rb
gris-0.5.4 lib/gris/grape_extensions/crud_helpers.rb
gris-0.5.3 lib/gris/grape_extensions/crud_helpers.rb
gris-0.5.2 lib/gris/grape_extensions/crud_helpers.rb
gris-0.5.1 lib/gris/grape_extensions/crud_helpers.rb
gris-0.5.0 lib/gris/grape_extensions/crud_helpers.rb
gris-0.4.9 lib/gris/grape_extensions/crud_helpers.rb
gris-0.4.8 lib/gris/grape_extensions/crud_helpers.rb
gris-0.4.7 lib/gris/grape_extensions/crud_helpers.rb