Sha256: 52943959bd2e392d3751df06682a467c6263884ba4fe71c6d6abfa262ce7d5c5

Contents?: true

Size: 655 Bytes

Versions: 2

Compression:

Stored size: 655 Bytes

Contents

module Loquor
  module Interactor
    module ClassMethods
      [:find, :find_each, :where, :create].each do |proxy|
        define_method proxy do |*args, &block|
          new.send proxy, *args, &block
        end
      end
    end

    module InstanceMethods
      def find(id)
        ApiCall::Show.new(self.class.path, id).execute
      end

      def find_each(&block)
        ApiCall::Index.new(self.class.path).find_each(&block)
      end

      def where(*args)
        ApiCall::Index.new(self.class.path).where(*args)
      end

      def create(payload)
        ApiCall::Create.new(self.class.path, payload).execute
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
loquor-0.2.0 lib/loquor/interactor.rb
loquor-0.1.2 lib/loquor/interactor.rb