Class: Card::Fetch
- Inherits:
-
Object
- Object
- Card::Fetch
- Defined in:
- lib/card/fetch.rb,
lib/card/fetch/all.rb,
lib/card/fetch/store.rb,
lib/card/fetch/results.rb,
lib/card/fetch/retrieve.rb,
lib/card/fetch/card_class.rb
Overview
retrieve card from cache or database, or (where needed) instantiate new card
Defined Under Namespace
Modules: All, CardClass, Results, Retrieve, Store
Instance Attribute Summary collapse
-
#card ⇒ Object
readonly
Returns the value of attribute card.
-
#mark ⇒ Object
readonly
Returns the value of attribute mark.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Fetch
constructor
see arg options in all/fetch.
- #local_only? ⇒ Boolean
- #look_in_trash? ⇒ Boolean
- #normalize_args(args) ⇒ Object
- #normalize_mark ⇒ Object
- #retrieve_or_new ⇒ Object
- #skip_modules? ⇒ Boolean
- #skip_type_lookup? ⇒ Boolean
- #validate_opts! ⇒ Object
Methods included from Store
#cache_ready?, #eager_caching?, #needs_prep?, #new_card_needed?, #new_for_cache, #new_for_cache?, #prep_for_cache, #reusable?, #update_cache, #update_cache?
Methods included from Results
#assign_name, #assignable_content, #fancy_renew?, #finalize_result_card, #name_change?, #new_opts, #new_result_card, #newish_opts, #quick_content, #quick_renew, #quick_renew?, #renew, #results, #supercard_might_change_type?, #type_change?, #type_id_from_new_opts, #update_supercard, #with_new_card
Methods included from Retrieve
#id_from_mark, #mark_type, #mark_value, #retrieval_from_db_query, #retrieval_from_db_query_base, #retrieve_existing, #retrieve_from_cache, #retrieve_from_db
Constructor Details
#initialize(*args) ⇒ Fetch
see arg options in all/fetch
11 12 13 14 |
# File 'lib/card/fetch.rb', line 11 def initialize *args normalize_args args validate_opts! end |
Instance Attribute Details
#card ⇒ Object (readonly)
Returns the value of attribute card.
8 9 10 |
# File 'lib/card/fetch.rb', line 8 def card @card end |
#mark ⇒ Object (readonly)
Returns the value of attribute mark.
8 9 10 |
# File 'lib/card/fetch.rb', line 8 def mark @mark end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
8 9 10 |
# File 'lib/card/fetch.rb', line 8 def opts @opts end |
Instance Method Details
#local_only? ⇒ Boolean
22 23 24 |
# File 'lib/card/fetch.rb', line 22 def local_only? opts[:local_only] end |
#look_in_trash? ⇒ Boolean
49 50 51 |
# File 'lib/card/fetch.rb', line 49 def look_in_trash? @opts[:look_in_trash] end |
#normalize_args(args) ⇒ Object
30 31 32 33 34 |
# 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 ⇒ Object
36 37 38 39 40 41 |
# 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 ⇒ Object
16 17 18 19 20 |
# File 'lib/card/fetch.rb', line 16 def retrieve_or_new retrieve_existing update_cache results end |
#skip_modules? ⇒ Boolean
26 27 28 |
# File 'lib/card/fetch.rb', line 26 def skip_modules? opts[:skip_modules] end |
#skip_type_lookup? ⇒ Boolean
53 54 55 |
# File 'lib/card/fetch.rb', line 53 def skip_type_lookup? opts[:skip_virtual] || opts[:skip_type_lookup] # || opts[:new] end |