Sha256: 7263309b024f9d2590165aab8970996b4c3af0d5dfe3e1353e8144871506edf6

Contents?: true

Size: 997 Bytes

Versions: 2

Compression:

Stored size: 997 Bytes

Contents

class Wallaby::ModelServicer
  def self.model_class
    if self < Wallaby::ModelServicer
      Wallaby::Utils.to_model_class name.gsub('Servicer', ''), name
    end
  end

  def initialize(model_class = nil, model_decorator = nil)
    @model_class      = model_class || self.class.model_class
    fail ArgumentError, 'model class required' unless @model_class
    @model_decorator  = model_decorator || Wallaby::DecoratorFinder.find_model(@model_class)
    @delegator        = Wallaby.adaptor.model_operator.new @model_class, @model_decorator
  end

  def collection(params, ability)
    @delegator.collection params, ability
  end

  def new(params)
    @delegator.new params
  end

  def find(id, params)
    @delegator.find id, params
  end

  def create(params, ability)
    @delegator.create params, ability
  end

  def update(resource, params, ability)
    @delegator.update resource, params, ability
  end

  def destroy(resource, params)
    @delegator.destroy resource, params
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wallaby-4.1.6 lib/services/wallaby/model_servicer.rb
wallaby-5.0.1 lib/services/wallaby/model_servicer.rb