Sha256: 1169ba335bc89fc0c26b3f8c596471e38b2c8ef20f7e95b00cb6ababb879a49b

Contents?: true

Size: 463 Bytes

Versions: 4

Compression:

Stored size: 463 Bytes

Contents

module Signaling::Base::Finders
  extend ActiveSupport::Concern

  module ClassMethods
    def find(id)
      from_response(request(:show, id: id))
    end

    def all(params = {})
      from_response(request(:index, params))
    end

    def from_response(response)
      case response
      when Hash, Hashie::Mash
        self.new(response)
      when Array
        response.map {|i| from_response(i) }
      else
        response
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
signaling-1.1.2 lib/signaling/base/finders.rb
signaling-1.1.1 lib/signaling/base/finders.rb
signaling-1.1.0 lib/signaling/base/finders.rb
signaling-1.0.0 lib/signaling/base/finders.rb