Class: Card
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Card
show all
- Extended by:
- CarrierWave::Mount
- Defined in:
- lib/card.rb,
lib/card/env.rb,
lib/card/set.rb,
lib/card/auth.rb,
lib/card/name.rb,
lib/card/cache.rb,
lib/card/error.rb,
lib/card/query.rb,
lib/card/stage.rb,
lib/card/format.rb,
lib/card/mailer.rb,
lib/card/content.rb,
lib/card/codename.rb,
lib/card/mod/dirs.rb,
lib/card/subcards.rb,
lib/card/reference.rb,
lib/card/set/event.rb,
lib/card/set/trait.rb,
lib/card/auth/proxy.rb,
lib/card/auth/setup.rb,
lib/card/mod/loader.rb,
lib/card/query/join.rb,
lib/card/set/basket.rb,
lib/card/set/format.rb,
lib/card/set/loader.rb,
lib/generators/card.rb,
lib/card/env/success.rb,
lib/card/format/nest.rb,
lib/card/query/value.rb,
lib/card/set/helpers.rb,
lib/card/set_pattern.rb,
lib/card/auth/current.rb,
lib/card/content/diff.rb,
lib/card/env/location.rb,
lib/card/format/error.rb,
lib/card/format/names.rb,
lib/card/content/chunk.rb,
lib/card/content/clean.rb,
lib/card/format/render.rb,
lib/card/query/helpers.rb,
lib/card/query/sorting.rb,
lib/card/content/parser.rb,
lib/card/format/content.rb,
lib/card/migration/core.rb,
lib/card/name/view_name.rb,
lib/card/stage_director.rb,
lib/card/cache/temporary.rb,
lib/card/set/inheritance.rb,
mod/history/lib/card/act.rb,
lib/card/auth/permissions.rb,
lib/card/cache/persistent.rb,
lib/card/cache/view_cache.rb,
lib/card/content/diff/lcs.rb,
lib/card/content/truncate.rb,
lib/card/format/nest/main.rb,
lib/card/format/nest/view.rb,
lib/card/migration/import.rb,
lib/card/query/attributes.rb,
lib/card/set/advanced_api.rb,
lib/card/cache/prepopulate.rb,
lib/card/director_register.rb,
lib/card/format/nest/fetch.rb,
lib/card/format/permission.rb,
lib/card/model/save_helper.rb,
lib/card/subdirector_array.rb,
lib/card/query/conjunctions.rb,
mod/history/lib/card/action.rb,
mod/history/lib/card/change.rb,
lib/card/content/diff/result.rb,
lib/card/format/registration.rb,
lib/card/query/sql_statement.rb,
lib/card/env/location_history.rb,
lib/card/query/interpretation.rb,
mod/machines/lib/card/machine.rb,
mod/settings/lib/card/setting.rb,
lib/card/format/nest/subformat.rb,
lib/card/content/diff/processor.rb,
mod/email/lib/card/follow_option.rb,
mod/history/lib/card/action/admin.rb,
mod/history/lib/card/action/differ.rb,
mod/machines/lib/card/machine_input.rb,
lib/card/query/relational_attributes.rb,
lib/card/migration/import/import_data.rb,
lib/generators/card/set/set_generator.rb,
lib/generators/card/format/format_generator.rb,
lib/generators/card/migration/migration_generator.rb,
mod/core/format/data_format.rb,
mod/core/format/html_format.rb,
mod/core/format/text_format.rb,
mod/basic_formats/format/js_format.rb,
mod/email/format/email_html_format.rb,
mod/email/format/email_text_format.rb,
mod/basic_formats/format/css_format.rb,
mod/basic_formats/format/csv_format.rb,
mod/basic_formats/format/rss_format.rb,
mod/basic_formats/format/xml_format.rb,
mod/basic_formats/format/file_format.rb,
mod/basic_formats/format/json_format.rb,
mod/core/chunk/include.rb,
mod/core/chunk/literal.rb,
mod/core/chunk/reference.rb,
tmpsets/set/mod001-core/all/erb.rb,
tmpsets/set/mod001-core/all/haml.rb,
tmpsets/set/mod001-core/all/name.rb,
tmpsets/set/mod001-core/all/type.rb,
tmpsets/set/mod001-core/all/event.rb,
tmpsets/set/mod001-core/all/fetch.rb,
tmpsets/set/mod001-core/all/rules.rb,
tmpsets/set/mod001-core/all/trash.rb,
tmpsets/set/mod001-core/all/utils.rb,
tmpsets/set/mod012-email/right/cc.rb,
tmpsets/set/mod012-email/right/to.rb,
tmpsets/set/mod001-core/all/actify.rb,
tmpsets/set/mod001-core/all/export.rb,
tmpsets/set/mod001-core/all/phases.rb,
tmpsets/set/mod001-core/all/stages.rb,
tmpsets/set/mod001-core/all/states.rb,
tmpsets/set/mod012-email/right/bcc.rb,
tmpsets/set/mod001-core/all/content.rb,
tmpsets/set/mod001-core/all/pattern.rb,
tmpsets/set/mod012-email/all/follow.rb,
tmpsets/set/mod012-email/all/notify.rb,
tmpsets/set/mod012-email/right/from.rb,
tmpsets/set/mod012-email/self/never.rb,
tmpsets/set/mod014-admin/self/admin.rb,
tmpsets/set/mod001-core/all/subcards.rb,
tmpsets/set/mod010-machines/type/css.rb,
tmpsets/set/mod012-email/self/always.rb,
tmpsets/set/mod012-email/self/edited.rb,
tmpsets/set/mod012-email/self/follow.rb,
tmpsets/set/mod016-standard/self/now.rb,
tmpsets/set/mod016-standard/type/set.rb,
tmpsets/set/mod016-standard/type/uri.rb,
tmpsets/set/mod017-account/type/user.rb,
tmpsets/set/mod010-machines/type/scss.rb,
tmpsets/set/mod010-machines/type/skin.rb,
tmpsets/set/mod011-settings/self/help.rb,
tmpsets/set/mod011-settings/self/read.rb,
tmpsets/set/mod012-email/all/observer.rb,
tmpsets/set/mod012-email/right/follow.rb,
tmpsets/set/mod012-email/self/created.rb,
tmpsets/set/mod014-admin/self/version.rb,
tmpsets/set/mod016-standard/all/error.rb,
tmpsets/set/mod016-standard/all/links.rb,
tmpsets/set/mod016-standard/self/foot.rb,
tmpsets/set/mod016-standard/type/date.rb,
tmpsets/set/mod016-standard/type/list.rb,
tmpsets/set/mod017-account/right/salt.rb,
tmpsets/set/mod001-core/all/collection.rb,
tmpsets/set/mod001-core/all/initialize.rb,
tmpsets/set/mod001-core/all/references.rb,
tmpsets/set/mod001-core/all/templating.rb,
tmpsets/set/mod001-core/all/view_cache.rb,
tmpsets/set/mod002-history/all/actions.rb,
tmpsets/set/mod002-history/all/history.rb,
tmpsets/set/mod011-settings/right/help.rb,
tmpsets/set/mod011-settings/right/read.rb,
tmpsets/set/mod011-settings/self/input.rb,
tmpsets/set/mod011-settings/self/style.rb,
tmpsets/set/mod016-standard/type/basic.rb,
tmpsets/set/mod017-account/all/account.rb,
tmpsets/set/mod017-account/right/email.rb,
tmpsets/set/mod017-account/right/token.rb,
tmpsets/set/mod017-account/self/signin.rb,
tmpsets/set/mod017-account/type/signup.rb,
tmpsets/set/mod001-core/all/active_card.rb,
tmpsets/set/mod001-core/all/permissions.rb,
tmpsets/set/mod004-pointer/type/pointer.rb,
tmpsets/set/mod011-settings/right/style.rb,
tmpsets/set/mod011-settings/self/create.rb,
tmpsets/set/mod011-settings/self/delete.rb,
tmpsets/set/mod011-settings/self/layout.rb,
tmpsets/set/mod011-settings/self/script.rb,
tmpsets/set/mod011-settings/self/thanks.rb,
tmpsets/set/mod011-settings/self/update.rb,
tmpsets/set/mod012-email/all/email_html.rb,
tmpsets/set/mod012-email/all/email_text.rb,
tmpsets/set/mod016-standard/all/comment.rb,
tmpsets/set/mod016-standard/rstar/rules.rb,
tmpsets/set/mod016-standard/self/alerts.rb,
tmpsets/set/mod016-standard/self/navbox.rb,
tmpsets/set/mod016-standard/self/recent.rb,
tmpsets/set/mod016-standard/self/search.rb,
tmpsets/set/mod016-standard/type/number.rb,
tmpsets/set/mod016-standard/type/phrase.rb,
tmpsets/set/mod016-standard/type/toggle.rb,
tmpsets/set/mod017-account/right/status.rb,
tmpsets/set/mod003-basic_formats/all/rss.rb,
tmpsets/set/mod009-basic_types/type/html.rb,
tmpsets/set/mod011-settings/right/create.rb,
tmpsets/set/mod011-settings/right/delete.rb,
tmpsets/set/mod011-settings/right/script.rb,
tmpsets/set/mod011-settings/right/update.rb,
tmpsets/set/mod011-settings/self/captcha.rb,
tmpsets/set/mod011-settings/self/default.rb,
tmpsets/set/mod011-settings/self/options.rb,
tmpsets/set/mod011-settings/type/setting.rb,
tmpsets/set/mod012-email/right/followers.rb,
tmpsets/set/mod012-email/right/following.rb,
tmpsets/set/mod013-carrierwave/type/file.rb,
tmpsets/set/mod014-admin/self/admin_info.rb,
tmpsets/set/mod015-developer/right/debug.rb,
tmpsets/set/mod016-standard/type/session.rb,
tmpsets/set/mod017-account/right/account.rb,
tmpsets/set/mod003-basic_formats/all/base.rb,
tmpsets/set/mod003-basic_formats/all/file.rb,
tmpsets/set/mod003-basic_formats/all/json.rb,
tmpsets/set/mod003-basic_formats/all/text.rb,
tmpsets/set/mod011-settings/right/comment.rb,
tmpsets/set/mod011-settings/right/default.rb,
tmpsets/set/mod011-settings/self/add_help.rb,
tmpsets/set/mod011-settings/self/autoname.rb,
tmpsets/set/mod013-carrierwave/type/image.rb,
tmpsets/set/mod015-developer/all/view_viz.rb,
tmpsets/set/mod016-standard/type/cardtype.rb,
tmpsets/set/mod017-account/right/password.rb,
tmpsets/set/mod001-core/abstract/code_file.rb,
tmpsets/set/mod003-basic_formats/self/head.rb,
tmpsets/set/mod011-settings/right/add_help.rb,
tmpsets/set/mod011-settings/self/on_create.rb,
tmpsets/set/mod011-settings/self/on_delete.rb,
tmpsets/set/mod011-settings/self/on_update.rb,
tmpsets/set/mod011-settings/self/structure.rb,
tmpsets/set/mod015-developer/all/event_viz.rb,
tmpsets/set/mod016-standard/self/codenames.rb,
tmpsets/set/mod016-standard/type/listed_by.rb,
tmpsets/set/mod003-basic_formats/all/all_js.rb,
tmpsets/set/mod004-pointer/self/script_mods.rb,
tmpsets/set/mod010-machines/abstract/script.rb,
tmpsets/set/mod011-settings/right/structure.rb,
tmpsets/set/mod012-email/right/html_message.rb,
tmpsets/set/mod001-core/all/location_history.rb,
tmpsets/set/mod001-core/all/name_validations.rb,
tmpsets/set/mod003-basic_formats/all/all_css.rb,
tmpsets/set/mod003-basic_formats/all/all_csv.rb,
tmpsets/set/mod010-machines/self/script_slot.rb,
tmpsets/set/mod010-machines/self/style_cards.rb,
tmpsets/set/mod010-machines/type/java_script.rb,
tmpsets/set/mod011-settings/self/accountable.rb,
tmpsets/set/mod012-email/right/follow_fields.rb,
tmpsets/set/mod012-email/type/email_template.rb,
tmpsets/set/mod016-standard/all/list_changes.rb,
tmpsets/set/mod016-standard/right/discussion.rb,
tmpsets/set/mod016-standard/type/layout_type.rb,
tmpsets/set/mod016-standard/type/search_type.rb,
tmpsets/set/mod005-ace_editor/self/script_ace.rb,
tmpsets/set/mod012-email/self/follow_defaults.rb,
tmpsets/set/mod017-account/self/account_links.rb,
tmpsets/set/mod018-bootstrap/self/script_mods.rb,
tmpsets/set/mod001-core/all/tracked_attributes.rb,
tmpsets/set/mod002-history/all/content_history.rb,
tmpsets/set/mod004-pointer/abstract/01_pointer.rb,
tmpsets/set/mod004-pointer/self/script_editors.rb,
tmpsets/set/mod008-solid_cache/all/solid_cache.rb,
tmpsets/set/mod009-basic_types/type/plain_text.rb,
tmpsets/set/mod010-machines/all/reset_machines.rb,
tmpsets/set/mod010-machines/self/script_jquery.rb,
tmpsets/set/mod010-machines/type/coffee_script.rb,
tmpsets/set/mod011-settings/self/follow_fields.rb,
tmpsets/set/mod011-settings/self/options_label.rb,
tmpsets/set/mod016-standard/all/rich_html/form.rb,
tmpsets/set/mod016-standard/all/rich_html/menu.rb,
tmpsets/set/mod016-standard/right/when_created.rb,
tmpsets/set/mod016-standard/rstar/rules_editor.rb,
tmpsets/set/mod018-bootstrap/self/bootstrap_js.rb,
tmpsets/set/mod018-bootstrap/self/smartmenu_js.rb,
tmpsets/set/mod010-machines/right/machine_cache.rb,
tmpsets/set/mod010-machines/right/machine_input.rb,
tmpsets/set/mod011-settings/abstract/permission.rb,
tmpsets/set/mod016-standard/all/rich_html/modal.rb,
tmpsets/set/mod018-bootstrap/all/bootstrap/form.rb,
tmpsets/set/mod018-bootstrap/all/bootstrap/tabs.rb,
tmpsets/set/mod018-bootstrap/all/rich_bootstrap.rb,
tmpsets/set/mod018-bootstrap/self/smartmenu_css.rb,
tmpsets/set/mod004-pointer/abstract/code_pointer.rb,
tmpsets/set/mod008-solid_cache/right/solid_cache.rb,
tmpsets/set/mod010-machines/right/machine_output.rb,
tmpsets/set/mod011-settings/self/recent_settings.rb,
tmpsets/set/mod016-standard/all/rich_html/header.rb,
tmpsets/set/mod018-bootstrap/all/bootstrap/table.rb,
tmpsets/set/mod005-ace_editor/abstract/ace_editor.rb,
tmpsets/set/mod010-machines/self/script_card_menu.rb,
tmpsets/set/mod016-standard/all/rich_html/content.rb,
tmpsets/set/mod016-standard/all/rich_html/editing.rb,
tmpsets/set/mod016-standard/all/rich_html/toolbar.rb,
tmpsets/set/mod016-standard/all/rich_html/wrapper.rb,
tmpsets/set/mod018-bootstrap/all/bootstrap/helper.rb,
tmpsets/set/mod018-bootstrap/self/bootstrap_cards.rb,
tmpsets/set/mod011-settings/self/default_html_view.rb,
tmpsets/set/mod011-settings/self/table_of_contents.rb,
tmpsets/set/mod013-carrierwave/abstract/attachment.rb,
tmpsets/set/mod016-standard/right/when_last_edited.rb,
tmpsets/set/mod018-bootstrap/all/bootstrap/wrapper.rb,
tmpsets/set/mod004-pointer/abstract/01_pointer/edit.rb,
tmpsets/set/mod008-solid_cache/abstract/solid_cache.rb,
tmpsets/set/mod018-bootstrap/self/bootswatch_shared.rb,
tmpsets/set/mod005-ace_editor/self/script_ace_config.rb,
tmpsets/set/mod012-email/type_plus_right/user/follow.rb,
tmpsets/set/mod004-pointer/self/script_pointer_config.rb,
tmpsets/set/mod010-machines/self/script_jquery_helper.rb,
tmpsets/set/mod003-basic_formats/self/01_head/javascript.rb,
tmpsets/set/mod010-machines/self/script_html5shiv_printshiv.rb,
tmpsets/set/mod010-machines/self/style_bootstrap_compatible.rb,
tmpsets/set/mod010-machines/self/style_jquery_ui_smoothness.rb,
tmpsets/set/mod006-prosemirror_editor/self/script_prosemirror.rb,
tmpsets/set/mod006-prosemirror_editor/abstract/prosemirror_editor.rb,
tmpsets/set/mod006-prosemirror_editor/self/script_prosemirror_config.rb
Overview
API to create/update/delete additional cards together with the main card.
The most common case is for fields but subcards don't have to be descendants.
Subcards can be added as card objects or attribute hashes.
Use the methods defined in core/set/all/subcards.rb
Example
Together with "my address" you want to create the subcards
"my address+name", "my address+street", etc.
Defined Under Namespace
Modules: Auth, Env, FollowOption, Generators, Machine, MachineInput, Mod, Model, Set, Setting, Stage, Version
Classes: Act, Action, Cache, Change, Codename, Content, DirectorRegister, Error, Format, Mailer, Migration, Name, Query, Reference, StageDirector, StageSubdirector, Subcards, SubdirectorArray
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#follower_stash ⇒ Object
Returns the value of attribute follower_stash.
61
62
63
|
# File 'lib/card.rb', line 61
def follower_stash
@follower_stash
end
|
Class Method Details
.cache ⇒ Object
5
6
7
|
# File 'lib/card/cache.rb', line 5
def cache
Card::Cache[Card]
end
|
.config ⇒ Object
8
9
10
|
# File 'lib/card/mod/loader.rb', line 8
def config
Cardio.config
end
|
.const_missing(const) ⇒ Integer
If a card has the codename example, then Card::ExampleID should
return the id for that card. This method makes that help.
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/card/codename.rb', line 84
def self.const_missing const
if const.to_s =~ /^([A-Z]\S*)ID$/ &&
(code = Regexp.last_match(1).underscore.to_sym)
if (card_id = Codename[code])
const_set const, card_id
else
raise "Missing codename #{code} (#{const})"
end
else
super
end
end
|
.expire(name) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/card/cache.rb', line 24
def expire name
key = name.to_name.key
return unless (card = Card.cache.read key)
Card.cache.delete key
Card.cache.delete "~#{card.id}" if card.id
end
|
.expire_hard(name) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/card/cache.rb', line 32
def expire_hard name
return unless Card.cache.hard
key = name.to_name.key
Card.cache.hard.delete key
Card.cache.hard.delete "~#{card.id}" if card.id
end
|
.new_director(card, opts = {}) ⇒ Object
.paths ⇒ Object
12
13
14
|
# File 'lib/card/mod/loader.rb', line 12
def paths
Cardio.paths
end
|
.serializable_attr_accessor(*args) ⇒ Object
attributes that ActiveJob can handle
16
17
18
19
|
# File 'lib/card.rb', line 16
def self.serializable_attr_accessor *args
self.serializable_attributes = args
attr_accessor(*args)
end
|
.write_to_cache(card, opts) ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/card/cache.rb', line 9
def write_to_cache card, opts
if opts[:local_only]
write_to_soft_cache card
elsif Card.cache
Card.cache.write card.key, card
Card.cache.write "~#{card.id}", card.key if card.id.to_i.nonzero?
end
end
|
.write_to_soft_cache(card) ⇒ Object
18
19
20
21
22
|
# File 'lib/card/cache.rb', line 18
def write_to_soft_cache card
return unless Card.cache
Card.cache.soft.write card.key, card
Card.cache.soft.write "~#{card.id}", card.key if card.id.to_i.nonzero?
end
|
Instance Method Details
#act(opts = {}) ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/card/director_register.rb', line 2
def act opts={}
if DirectorRegister.act_card
if DirectorRegister.act_card != self && !only_storage_phase
director.reset_stage
if opts && opts[:trash]
@action = :delete
else
identify_action
end
director.update_card self
self.only_storage_phase = true
end
main_act_block = false
else
DirectorRegister.clear
self.director = nil
DirectorRegister.act_card = self
main_act_block = true
if opts && opts[:success]
Env[:success] = Env::Success.new(cardname, Env.params[:success])
end
end
yield
ensure
DirectorRegister.clear if main_act_block
end
|
#clean_after_stage_fail ⇒ Object
11
12
13
14
15
|
# File 'lib/card/stage_director.rb', line 11
def clean_after_stage_fail
@action = nil
expire_pieces
subcards.each(&:expire_pieces)
end
|
#deserialize_for_active_job!(attr, env, current_id) ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/card/set/event.rb', line 2
def deserialize_for_active_job! attr, env, current_id
attr.each do |attname, args|
value = args[:symbol] ? args[:value].to_sym : args[:value]
instance_variable_set("@#{attname}", value)
end
include_set_modules
return if Wagn.config.active_job.queue_adapter == :inline
Card::Env.deserialize! env
Card::Auth.current_id = current_id
end
|
#expire_subcards ⇒ Object
18
19
20
|
# File 'lib/card/subcards.rb', line 18
def expire_subcards
subcards.clear
end
|
#left_id=(card_or_id) ⇒ Object
292
293
294
|
# File 'lib/card/subcards.rb', line 292
def left_id= card_or_id
write_card_or_id :left_id, card_or_id
end
|
#log_event_call(event) ⇒ Object
34
35
36
37
|
# File 'lib/card/set/event.rb', line 34
def log_event_call event
Rails.logger.debug "#{name}: #{event}"
end
|
3
4
5
6
7
8
9
|
# File 'lib/card/stage_director.rb', line 3
def restore_changes_information
return unless @previously_changed
@changed_attributes = ActiveSupport::HashWithIndifferentAccess.new
@previously_changed.each do |k, (old, _new)|
@changed_attributes[k] = old
end
end
|
#right_id=(card_or_id) ⇒ Object
288
289
290
|
# File 'lib/card/subcards.rb', line 288
def right_id= card_or_id
write_card_or_id :right_id, card_or_id
end
|
#serialize_for_active_job ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/card/set/event.rb', line 21
def serialize_for_active_job
serializable_attributes.each_with_object({}) do |name, hash|
value = instance_variable_get("@#{name}")
hash[name] =
if value.is_a? Symbol
{ value: value.to_s, symbol: true }
else
{ value: value }
end
end
end
|
#subcards ⇒ Object
13
14
15
16
|
# File 'lib/card/subcards.rb', line 13
def subcards
@subcards ||= Subcards.new(self)
end
|
#type_id=(card_or_id) ⇒ Object
296
297
298
|
# File 'lib/card/subcards.rb', line 296
def type_id= card_or_id
write_card_or_id :type_id, card_or_id
end
|
#with_id_when_exists(card, &block) ⇒ Object
317
318
319
|
# File 'lib/card/subcards.rb', line 317
def with_id_when_exists card, &block
card.director.call_after_store(&block)
end
|
#write_card_or_id(attribute, card_or_id) ⇒ Object
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
|
# File 'lib/card/subcards.rb', line 300
def write_card_or_id attribute, card_or_id
if card_or_id.is_a? Card
card = card_or_id
if card.id
write_attribute attribute, card.id
else
add_subcard card
card.director.prior_store = true
with_id_when_exists(card) do |id|
write_attribute attribute, id
end
end
else
write_attribute attribute, card_or_id
end
end
|