Module: Card::Set::All::Trash
- Extended by:
- Card::Set
- Defined in:
- platypus/tmp/set/gem-card/mod001-core/all/trash.rb
Overview
Constant Summary
Constants included
from Helpers
Helpers::SET_PATTERN_TEST_REGEXP
Constants included
from Event::Api
Event::Api::OPTIONS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Card::Set
reset
Methods included from I18nScope
#mod_name, #scope
Methods included from Registrar
#extended, #finalize_load, #process_base_modules, #register_set
Methods included from Helpers
#format_module, #format_modules, #method_missing, #modules, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscored_name
#assign_type, #attachment, #define_set_from_error, #ensure_set, #setting_opts, #stage_method
Methods included from Format
#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name
#include_set, #include_set_formats
Methods included from Trait
#card_accessor, #card_reader, #card_writer, #require_field
Methods included from Event::Api
#event
Class Method Details
.source_location ⇒ Object
7
|
# File 'platypus/tmp/set/gem-card/mod001-core/all/trash.rb', line 7
def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/core/set/all/trash.rb"; end
|
Instance Method Details
#add_to_trash(args) {|args.merge(trash: true)| ... } ⇒ Object
77
78
79
|
# File 'platypus/tmp/set/gem-card/mod001-core/all/trash.rb', line 77
def add_to_trash args
yield args.merge(trash: true) unless new_card?
end
|
#db_attributes ⇒ Object
81
82
83
|
# File 'platypus/tmp/set/gem-card/mod001-core/all/trash.rb', line 81
def db_attributes
send(:mutations_from_database).send :attributes
end
|
#delete(args = {}) ⇒ Object
18
19
20
21
22
|
# File 'platypus/tmp/set/gem-card/mod001-core/all/trash.rb', line 18
def delete args={}
add_to_trash args do |delete_args|
update delete_args
end
end
|
#delete!(args = {}) ⇒ Object
24
25
26
27
28
|
# File 'platypus/tmp/set/gem-card/mod001-core/all/trash.rb', line 24
def delete! args={}
add_to_trash args do |delete_args|
update! delete_args
end
end
|
#delete_as_subcard(subcard) ⇒ Object
85
86
87
88
|
# File 'platypus/tmp/set/gem-card/mod001-core/all/trash.rb', line 85
def delete_as_subcard subcard
subcard.trash = true
subcard subcard
end
|
#event: delete_children ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'platypus/tmp/set/gem-card/mod001-core/all/trash.rb', line 53
event :delete_children, after: :validate_delete, on: :delete do
return if errors.any?
each_child do |child|
child.include_set_modules
delete_as_subcard child
end
end
|
#event: manage_trash ⇒ Object
30
31
32
33
34
|
# File 'platypus/tmp/set/gem-card/mod001-core/all/trash.rb', line 30
event :manage_trash, :prepare_to_store, on: :create do
pull_from_trash!
self.trash = false
true
end
|
#event: validate_delete ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'platypus/tmp/set/gem-card/mod001-core/all/trash.rb', line 36
event :validate_delete, :validate, on: :delete do
unless codename.blank?
errors.add :delete, t(:core_error_system_card, name: name, codename: codename)
end
undeletable_all_rules_tags =
%w[default style layout create read update delete]
if compound? && left&.codename == :all &&
undeletable_all_rules_tags.member?(right.codename.to_s)
errors.add :delete, t(:core_error_indestructible, name: name)
end
errors.add :delete, t(:core_error_user_edits, name: name) if account && has_edits?
end
|
#pull_from_trash! ⇒ Object
66
67
68
69
70
71
72
73
74
75
|
# File 'platypus/tmp/set/gem-card/mod001-core/all/trash.rb', line 66
def pull_from_trash!
query = Lexicon.lex_query(lex).merge trash: true
return unless (trashed_card = Card.where(query).take)
db_attributes["id"] = trashed_card.db_attributes["id"]
@from_trash = true
@new_record = false
end
|
#trash? ⇒ Boolean
14
15
16
|
# File 'platypus/tmp/set/gem-card/mod001-core/all/trash.rb', line 14
def trash?
trash
end
|