Module: Card::Set::All::Fetch
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod001-core/all/fetch.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary
collapse
Methods included from Loader
#clean_empty_module_from_hash, #clean_empty_modules, #extended, #pattern_and_modules_from_path, #process_base_modules, #register_set, #tmp_file_template, #write_tmp_file
Methods included from Helpers
#abstract_set?, #all_set?, #shortname
#attachment, #ensure_set, #stage_method
Methods included from Format
#all_set_format_mod!, #define_on_format, #format, #register_set_format, #view
#include_set, #include_set_formats
Methods included from Basket
#abstract_basket, #add_to_basket, #basket
Methods included from Trait
#card_accessor, #card_reader, #card_writer
Methods included from Event
#event
Instance Method Details
#eager_renew?(opts) ⇒ Boolean
319
320
321
|
# File 'tmpsets/set/mod001-core/all/fetch.rb', line 319
def eager_renew? opts
opts[:skip_virtual] && new_card? && opts[:new].present?
end
|
#expire ⇒ Object
304
305
306
307
|
# File 'tmpsets/set/mod001-core/all/fetch.rb', line 304
def expire
expire_hard
expire_soft
end
|
#expire_hard ⇒ Object
293
294
295
296
297
|
# File 'tmpsets/set/mod001-core/all/fetch.rb', line 293
def expire_hard
return unless Card.cache.hard
Card.cache.hard.delete key
Card.cache.hard.delete "~#{id}" if id
end
|
#expire_pieces ⇒ Object
287
288
289
290
291
|
# File 'tmpsets/set/mod001-core/all/fetch.rb', line 287
def expire_pieces
cardname.piece_names.each do |piece|
Card.expire piece
end
end
|
#expire_soft ⇒ Object
299
300
301
302
|
# File 'tmpsets/set/mod001-core/all/fetch.rb', line 299
def expire_soft
Card.cache.soft.delete key
Card.cache.soft.delete "~#{id}" if id
end
|
#fetch(opts = {}) ⇒ Object
~~~~~~~~~~ Instance ~~~~~~~~~~~~~
260
261
262
263
264
265
266
267
268
|
# File 'tmpsets/set/mod001-core/all/fetch.rb', line 260
def fetch opts={}
traits = opts.delete(:trait)
return unless traits
traits = Array.wrap traits
traits.inject(self) do |card, trait|
Card.fetch card.cardname.trait(trait), opts
end
end
|
#handle_default_content(opts) ⇒ Object
278
279
280
281
282
283
284
285
|
# File 'tmpsets/set/mod001-core/all/fetch.rb', line 278
def handle_default_content opts
if (default_content = opts.delete(:default_content)) && db_content.blank?
opts[:content] ||= default_content
elsif db_content.present? && !opts[:content]
opts[:content] = db_content
end
end
|
#name_from_mark!(mark, opts) ⇒ Object
327
328
329
330
331
|
# File 'tmpsets/set/mod001-core/all/fetch.rb', line 327
def name_from_mark! mark, opts
return if opts[:local_only]
return unless mark && mark.to_s != name
self.name = mark.to_s
end
|
#refresh(force = false) ⇒ Object
309
310
311
312
313
314
315
316
317
|
# File 'tmpsets/set/mod001-core/all/fetch.rb', line 309
def refresh force=false
if force || frozen? || readonly?
fresh_card = self.class.find id
fresh_card.include_set_modules
fresh_card
else
self
end
end
|
#renew(args = {}) ⇒ Object
270
271
272
273
274
275
276
|
# File 'tmpsets/set/mod001-core/all/fetch.rb', line 270
def renew args={}
opts = args[:new].clone
handle_default_content opts
opts[:name] ||= cardname
opts[:skip_modules] = args[:skip_modules]
Card.new opts
end
|
#type_known? ⇒ Boolean
323
324
325
|
# File 'tmpsets/set/mod001-core/all/fetch.rb', line 323
def type_known?
type_id.present?
end
|