class Card::Fetch
retrieve card from cache or database, or (where needed) instantiate new card
Attributes
card[R]
mark[R]
opts[R]
Public Class Methods
new(*args)
click to toggle source
see arg options in all/fetch
# File lib/card/fetch.rb, line 11 def initialize *args normalize_args args validate_opts! end
Public Instance Methods
local_only?()
click to toggle source
# File lib/card/fetch.rb, line 22 def local_only? opts[:local_only] end
look_in_trash?()
click to toggle source
# File lib/card/fetch.rb, line 49 def look_in_trash? @opts[:look_in_trash] end
normalize_args(args)
click to toggle source
# File lib/card/fetch.rb, line 30 def normalize_args args @opts = args.last.is_a?(Hash) ? args.pop : {} @mark = Card.id_or_name args normalize_mark end
normalize_mark()
click to toggle source
# File lib/card/fetch.rb, line 36 def normalize_mark return unless mark.name? supercard = opts.dig :new, :supercard @mark = mark.absolute_name supercard.name if supercard end
retrieve_or_new()
click to toggle source
# File lib/card/fetch.rb, line 16 def retrieve_or_new retrieve_existing update_cache results end
skip_modules?()
click to toggle source
# File lib/card/fetch.rb, line 26 def skip_modules? opts[:skip_modules] end
skip_type_lookup?()
click to toggle source
# File lib/card/fetch.rb, line 53 def skip_type_lookup? opts[:skip_virtual] || opts[:skip_type_lookup] # || opts[:new] end
validate_opts!()
click to toggle source
# File lib/card/fetch.rb, line 43 def validate_opts! return unless opts[:new] && opts[:skip_virtual] raise Card::Error, "fetch called with new args and skip_virtual" end