class Troo::Retrieval::Local
Attributes
id[R]
klass[R]
Public Class Methods
all(klass)
click to toggle source
@param [] @return []
# File lib/troo/retrieval/local.rb, line 9 def all(klass) new(klass).all end
default(klass, options = {})
click to toggle source
@param [] @param [Hash] @return []
# File lib/troo/retrieval/local.rb, line 16 def default(klass, options = {}) new(klass, nil, options).default end
new(klass, id = nil, options = {})
click to toggle source
@param [] @param [] @param [Hash] @return []
# File lib/troo/retrieval/local.rb, line 33 def initialize(klass, id = nil, options = {}) @klass, @id, @options = klass, id, options end
retrieve(klass, id = nil, options = {})
click to toggle source
@param [] @param [] @param [Hash] @return []
# File lib/troo/retrieval/local.rb, line 24 def retrieve(klass, id = nil, options = {}) new(klass, id, options).retrieve end
Public Instance Methods
all()
click to toggle source
@return []
# File lib/troo/retrieval/local.rb, line 38 def all klass.all end
default()
click to toggle source
@return []
# File lib/troo/retrieval/local.rb, line 43 def default klass.default end
retrieve()
click to toggle source
@return []
# File lib/troo/retrieval/local.rb, line 48 def retrieve return default unless id by_short_id || by_id || by_external_id || optional_remote end
Private Instance Methods
allow_remote?()
click to toggle source
# File lib/troo/retrieval/local.rb, line 61 def allow_remote? Troo.configuration.allow_remote && options.fetch(:allow_remote) end
board_criteria()
click to toggle source
# File lib/troo/retrieval/local.rb, line 107 def board_criteria { external_board_id: Troo::Board.default.external_id } end
by_external_id()
click to toggle source
# File lib/troo/retrieval/local.rb, line 82 def by_external_id klass.by_external_id(id) end
by_id()
click to toggle source
# File lib/troo/retrieval/local.rb, line 74 def by_id klass[id] end
by_short_id()
click to toggle source
# File lib/troo/retrieval/local.rb, line 78 def by_short_id klass.first(short_id_criteria) end
card?()
click to toggle source
# File lib/troo/retrieval/local.rb, line 111 def card? klass.type.eql?(:card) end
default_board_exists?()
click to toggle source
# File lib/troo/retrieval/local.rb, line 115 def default_board_exists? !!(Troo::Board.default) end
defaults()
click to toggle source
# File lib/troo/retrieval/local.rb, line 70 def defaults { allow_remote: true } end
normal()
click to toggle source
# File lib/troo/retrieval/local.rb, line 95 def normal { short_id: id } end
optional_remote()
click to toggle source
# File lib/troo/retrieval/local.rb, line 57 def optional_remote remote if allow_remote? end
options()
click to toggle source
# File lib/troo/retrieval/local.rb, line 66 def options defaults.merge!(@options) end
remote()
click to toggle source
# File lib/troo/retrieval/local.rb, line 86 def remote Retrieval::Remote.fetch(klass.remote, id, options).first end
short_id_criteria()
click to toggle source
# File lib/troo/retrieval/local.rb, line 90 def short_id_criteria return special if card? && default_board_exists? normal end
special()
click to toggle source
# File lib/troo/retrieval/local.rb, line 99 def special if klass.count(normal) > 1 normal.merge!(board_criteria) else normal end end