Sha256: db98f5d07bc68b870dcdd844d40dfb40421ef4f5117cfa35a3d16d3f6aeee30a

Contents?: true

Size: 535 Bytes

Versions: 6

Compression:

Stored size: 535 Bytes

Contents

module Troo
  class MemberRetrieval
    class << self
      def all
        Troo::Member.all
      end

      def retrieve(id)
        new(id).retrieve
      end
    end

    def initialize(id)
      @id = id
    end

    def retrieve
      by_id || by_external_id || remote
    end

    private
    attr_reader :id

    def by_id
      Troo::Member[id]
    end

    def by_external_id
      Troo::Member.first(external_member_id: id)
    end

    def remote
      External::Member.fetch(id, { mode: :member }).first
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
troo-0.0.7 lib/troo/models/member_retrieval.rb
troo-0.0.6 lib/troo/models/member_retrieval.rb
troo-0.0.5 lib/troo/models/member_retrieval.rb
troo-0.0.4 lib/troo/models/member_retrieval.rb
troo-0.0.3 lib/troo/models/member_retrieval.rb
troo-0.0.2 lib/troo/models/member_retrieval.rb