class Troo::Retrieval::Remote
Attributes
external_id[R]
klass[R]
Public Class Methods
fetch(klass, external_id, options = {})
click to toggle source
@param [] @param [] @param [Hash] @return []
# File lib/troo/retrieval/remote.rb, line 11 def fetch(klass, external_id, options = {}) new(klass, external_id, options).fetch end
new(klass, external_id, options = {})
click to toggle source
@param [] @param [] @param [Hash] @return [Troo::Retrieval::Remote]
# File lib/troo/retrieval/remote.rb, line 20 def initialize(klass, external_id, options = {}) @klass = klass @external_id = external_id @options = options end
Public Instance Methods
fetch()
click to toggle source
@return [Array]
# File lib/troo/retrieval/remote.rb, line 27 def fetch return [] if none? return persist if persist? resources end
Private Instance Methods
defaults()
click to toggle source
# File lib/troo/retrieval/remote.rb, line 91 def defaults { mode: :none, persist: true } end
interpolation()
click to toggle source
# File lib/troo/retrieval/remote.rb, line 95 def interpolation { external_id: external_id } end
mode()
click to toggle source
# File lib/troo/retrieval/remote.rb, line 75 def mode options.fetch(:mode, :none) end
modes()
click to toggle source
# File lib/troo/retrieval/remote.rb, line 64 def modes { all: klass.all, board: klass.by_board_id, list: klass.by_list_id, card: klass.by_card_id, member: klass.by_member_id, none: {} } end
none?()
click to toggle source
# File lib/troo/retrieval/remote.rb, line 37 def none? resources.empty? end
options()
click to toggle source
# File lib/troo/retrieval/remote.rb, line 83 def options remote_options.merge!(@options) end
parameters()
click to toggle source
# File lib/troo/retrieval/remote.rb, line 50 def parameters { verb: :get, endpoint: nil, interpolation: interpolation, query: {}, model: klass }.merge!(resource_parameters) end
persist()
click to toggle source
# File lib/troo/retrieval/remote.rb, line 41 def persist @persisted ||= Troo::Persistence::Local .with_collection(resources) end
persist?()
click to toggle source
# File lib/troo/retrieval/remote.rb, line 79 def persist? options.fetch(:persist) end
remote_options()
click to toggle source
# File lib/troo/retrieval/remote.rb, line 87 def remote_options defaults.merge!(klass.remote_options) end
resource_parameters()
click to toggle source
# File lib/troo/retrieval/remote.rb, line 60 def resource_parameters modes.fetch(mode) end
resources()
click to toggle source
# File lib/troo/retrieval/remote.rb, line 46 def resources @resources ||= API::Client.perform(parameters) end