Class: Card

Inherits:
ActiveRecord::Base
  • Object
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/diff.rb,
lib/card/name.rb,
lib/card/cache.rb,
lib/card/query.rb,
lib/card/stage.rb,
lib/card/format.rb,
lib/card/loader.rb,
lib/card/mailer.rb,
lib/card/content.rb,
lib/card/success.rb,
lib/card/codename.rb,
lib/card/diff/lcs.rb,
lib/card/location.rb,
lib/card/subcards.rb,
lib/card/reference.rb,
lib/card/set/event.rb,
lib/card/view_name.rb,
lib/card/exceptions.rb,
lib/card/query/join.rb,
lib/card/view_cache.rb,
lib/generators/card.rb,
lib/card/diff/result.rb,
lib/card/format/nest.rb,
lib/card/query/value.rb,
lib/card/set_pattern.rb,
lib/card/content/chunk.rb,
lib/card/format/render.rb,
lib/card/content/parser.rb,
lib/card/stage_director.rb,
lib/card/query/attributes.rb,
lib/card/director_register.rb,
lib/card/format/permission.rb,
lib/card/subdirector_array.rb,
mod/01_history/lib/card/act.rb,
lib/card/query/sql_statement.rb,
lib/card/active_record_helper.rb,
mod/01_history/lib/card/action.rb,
mod/01_history/lib/card/change.rb,
mod/03_machines/lib/card/machine.rb,
mod/04_settings/lib/card/setting.rb,
mod/05_email/lib/card/follow_option.rb,
lib/generators/card/set/set_generator.rb,
mod/03_machines/lib/card/machine_input.rb,
lib/generators/card/format/format_generator.rb,
lib/generators/card/migration/migration_generator.rb,
tmpsets/set/mod001-01_core/all/erb.rb,
tmpsets/set/mod001-01_core/all/haml.rb,
tmpsets/set/mod001-01_core/all/name.rb,
tmpsets/set/mod001-01_core/all/type.rb,
tmpsets/set/mod001-01_core/all/fetch.rb,
tmpsets/set/mod001-01_core/all/rules.rb,
tmpsets/set/mod001-01_core/all/trash.rb,
tmpsets/set/mod001-01_core/all/utils.rb,
tmpsets/set/mod006-05_email/right/cc.rb,
tmpsets/set/mod006-05_email/right/to.rb,
tmpsets/set/mod001-01_core/all/phases.rb,
tmpsets/set/mod001-01_core/all/states.rb,
tmpsets/set/mod006-05_email/right/bcc.rb,
tmpsets/set/mod001-01_core/all/content.rb,
tmpsets/set/mod001-01_core/all/pattern.rb,
tmpsets/set/mod006-05_email/all/follow.rb,
tmpsets/set/mod006-05_email/all/notify.rb,
tmpsets/set/mod006-05_email/right/from.rb,
tmpsets/set/mod006-05_email/self/never.rb,
tmpsets/set/mod004-03_machines/type/css.rb,
tmpsets/set/mod006-05_email/self/always.rb,
tmpsets/set/mod006-05_email/self/edited.rb,
tmpsets/set/mod006-05_email/self/follow.rb,
tmpsets/set/mod007-05_standard/self/all.rb,
tmpsets/set/mod007-05_standard/self/now.rb,
tmpsets/set/mod007-05_standard/type/set.rb,
tmpsets/set/mod007-05_standard/type/uri.rb,
tmpsets/set/mod004-03_machines/type/scss.rb,
tmpsets/set/mod004-03_machines/type/skin.rb,
tmpsets/set/mod005-04_settings/self/help.rb,
tmpsets/set/mod005-04_settings/self/read.rb,
tmpsets/set/mod006-05_email/all/observer.rb,
tmpsets/set/mod006-05_email/right/follow.rb,
tmpsets/set/mod006-05_email/self/created.rb,
tmpsets/set/mod007-05_standard/all/error.rb,
tmpsets/set/mod007-05_standard/all/links.rb,
tmpsets/set/mod007-05_standard/self/foot.rb,
tmpsets/set/mod007-05_standard/self/head.rb,
tmpsets/set/mod007-05_standard/type/date.rb,
tmpsets/set/mod007-05_standard/type/file.rb,
tmpsets/set/mod007-05_standard/type/user.rb,
tmpsets/set/mod001-01_core/all/collection.rb,
tmpsets/set/mod001-01_core/all/initialize.rb,
tmpsets/set/mod001-01_core/all/references.rb,
tmpsets/set/mod001-01_core/all/templating.rb,
tmpsets/set/mod001-01_core/all/view_cache.rb,
tmpsets/set/mod002-01_history/all/actions.rb,
tmpsets/set/mod002-01_history/all/history.rb,
tmpsets/set/mod003-02_basic_types/all/rss.rb,
tmpsets/set/mod005-04_settings/right/help.rb,
tmpsets/set/mod005-04_settings/right/read.rb,
tmpsets/set/mod005-04_settings/self/input.rb,
tmpsets/set/mod005-04_settings/self/style.rb,
tmpsets/set/mod007-05_standard/right/salt.rb,
tmpsets/set/mod007-05_standard/self/stats.rb,
tmpsets/set/mod007-05_standard/type/basic.rb,
tmpsets/set/mod007-05_standard/type/image.rb,
tmpsets/set/mod001-01_core/all/active_card.rb,
tmpsets/set/mod001-01_core/all/permissions.rb,
tmpsets/set/mod003-02_basic_types/all/base.rb,
tmpsets/set/mod003-02_basic_types/all/file.rb,
tmpsets/set/mod003-02_basic_types/all/json.rb,
tmpsets/set/mod003-02_basic_types/all/text.rb,
tmpsets/set/mod005-04_settings/right/style.rb,
tmpsets/set/mod005-04_settings/self/create.rb,
tmpsets/set/mod005-04_settings/self/delete.rb,
tmpsets/set/mod005-04_settings/self/layout.rb,
tmpsets/set/mod005-04_settings/self/script.rb,
tmpsets/set/mod005-04_settings/self/thanks.rb,
tmpsets/set/mod005-04_settings/self/update.rb,
tmpsets/set/mod006-05_email/all/email_html.rb,
tmpsets/set/mod006-05_email/all/email_text.rb,
tmpsets/set/mod007-05_standard/all/account.rb,
tmpsets/set/mod007-05_standard/all/comment.rb,
tmpsets/set/mod007-05_standard/right/email.rb,
tmpsets/set/mod007-05_standard/right/stats.rb,
tmpsets/set/mod007-05_standard/right/token.rb,
tmpsets/set/mod007-05_standard/rstar/rules.rb,
tmpsets/set/mod007-05_standard/self/alerts.rb,
tmpsets/set/mod007-05_standard/self/navbox.rb,
tmpsets/set/mod007-05_standard/self/recent.rb,
tmpsets/set/mod007-05_standard/self/search.rb,
tmpsets/set/mod007-05_standard/self/signin.rb,
tmpsets/set/mod007-05_standard/type/number.rb,
tmpsets/set/mod007-05_standard/type/phrase.rb,
tmpsets/set/mod007-05_standard/type/signup.rb,
tmpsets/set/mod007-05_standard/type/toggle.rb,
tmpsets/set/mod003-02_basic_types/type/html.rb,
tmpsets/set/mod005-04_settings/right/create.rb,
tmpsets/set/mod005-04_settings/right/delete.rb,
tmpsets/set/mod005-04_settings/right/script.rb,
tmpsets/set/mod005-04_settings/right/update.rb,
tmpsets/set/mod005-04_settings/self/captcha.rb,
tmpsets/set/mod005-04_settings/self/default.rb,
tmpsets/set/mod005-04_settings/self/options.rb,
tmpsets/set/mod005-04_settings/type/setting.rb,
tmpsets/set/mod006-05_email/right/followers.rb,
tmpsets/set/mod006-05_email/right/following.rb,
tmpsets/set/mod007-05_standard/right/status.rb,
tmpsets/set/mod007-05_standard/self/version.rb,
tmpsets/set/mod007-05_standard/type/session.rb,
tmpsets/set/mod003-02_basic_types/all/all_js.rb,
tmpsets/set/mod005-04_settings/right/comment.rb,
tmpsets/set/mod005-04_settings/right/default.rb,
tmpsets/set/mod005-04_settings/self/add_help.rb,
tmpsets/set/mod005-04_settings/self/autoname.rb,
tmpsets/set/mod007-05_standard/all/event_viz.rb,
tmpsets/set/mod007-05_standard/right/account.rb,
tmpsets/set/mod007-05_standard/type/cardtype.rb,
tmpsets/set/mod003-02_basic_types/all/all_css.rb,
tmpsets/set/mod003-02_basic_types/all/all_csv.rb,
tmpsets/set/mod005-04_settings/right/add_help.rb,
tmpsets/set/mod005-04_settings/self/on_create.rb,
tmpsets/set/mod005-04_settings/self/on_delete.rb,
tmpsets/set/mod005-04_settings/self/on_update.rb,
tmpsets/set/mod005-04_settings/self/structure.rb,
tmpsets/set/mod007-05_standard/right/password.rb,
tmpsets/set/mod003-02_basic_types/type/pointer.rb,
tmpsets/set/mod004-03_machines/self/script_ace.rb,
tmpsets/set/mod005-04_settings/right/structure.rb,
tmpsets/set/mod006-05_email/right/html_message.rb,
tmpsets/set/mod004-03_machines/self/script_slot.rb,
tmpsets/set/mod004-03_machines/self/style_cards.rb,
tmpsets/set/mod004-03_machines/type/java_script.rb,
tmpsets/set/mod005-04_settings/self/accountable.rb,
tmpsets/set/mod006-05_email/right/follow_fields.rb,
tmpsets/set/mod006-05_email/type/email_template.rb,
tmpsets/set/mod007-05_standard/right/discussion.rb,
tmpsets/set/mod007-05_standard/type/layout_type.rb,
tmpsets/set/mod007-05_standard/type/search_type.rb,
tmpsets/set/mod006-05_email/self/follow_defaults.rb,
tmpsets/set/mod001-01_core/all/tracked_attributes.rb,
tmpsets/set/mod002-01_history/all/content_history.rb,
tmpsets/set/mod003-02_basic_types/type/plain_text.rb,
tmpsets/set/mod004-03_machines/self/script_jquery.rb,
tmpsets/set/mod004-03_machines/type/coffee_script.rb,
tmpsets/set/mod005-04_settings/self/options_label.rb,
tmpsets/set/mod007-05_standard/all/rich_html/form.rb,
tmpsets/set/mod007-05_standard/all/rich_html/menu.rb,
tmpsets/set/mod007-05_standard/right/when_created.rb,
tmpsets/set/mod007-05_standard/self/account_links.rb,
tmpsets/set/mod008-06_bootstrap/self/bootstrap_js.rb,
tmpsets/set/mod008-06_bootstrap/self/smartmenu_js.rb,
tmpsets/set/mod004-03_machines/right/machine_input.rb,
tmpsets/set/mod004-03_machines/self/script_tinymce.rb,
tmpsets/set/mod005-04_settings/abstract/permission.rb,
tmpsets/set/mod007-05_standard/abstract/attachment.rb,
tmpsets/set/mod007-05_standard/all/rich_html/modal.rb,
tmpsets/set/mod008-06_bootstrap/all/bootstrap/form.rb,
tmpsets/set/mod008-06_bootstrap/all/rich_bootstrap.rb,
tmpsets/set/mod008-06_bootstrap/self/smartmenu_css.rb,
tmpsets/set/mod004-03_machines/right/machine_output.rb,
tmpsets/set/mod005-04_settings/self/recent_settings.rb,
tmpsets/set/mod007-05_standard/all/rich_html/header.rb,
tmpsets/set/mod007-05_standard/self/performance_log.rb,
tmpsets/set/mod004-03_machines/self/script_card_menu.rb,
tmpsets/set/mod007-05_standard/all/rich_html/content.rb,
tmpsets/set/mod007-05_standard/all/rich_html/editing.rb,
tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb,
tmpsets/set/mod007-05_standard/all/rich_html/wrapper.rb,
tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb,
tmpsets/set/mod008-06_bootstrap/self/bootstrap_cards.rb,
tmpsets/set/mod005-04_settings/self/table_of_contents.rb,
tmpsets/set/mod007-05_standard/right/when_last_edited.rb,
tmpsets/set/mod008-06_bootstrap/all/bootstrap/wrapper.rb,
tmpsets/set/mod008-06_bootstrap/self/bootswatch_shared.rb,
tmpsets/set/mod006-05_email/type_plus_right/user/follow.rb,
tmpsets/set/mod004-03_machines/self/script_jquery_helper.rb,
tmpsets/set/mod004-03_machines/self/script_html5shiv_printshiv.rb,
tmpsets/set/mod004-03_machines/self/style_bootstrap_compatible.rb,
tmpsets/set/mod004-03_machines/self/style_jquery_ui_smoothness.rb

Overview

~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/self/performance_log.rb ~~~~~~~~~~~

Defined Under Namespace

Modules: ActiveRecordHelper, Auth, Env, FollowOption, Generators, Loader, Location, Machine, MachineInput, Set, Setting, SpecHelper, Stage, Version, ViewCache Classes: Abort, Act, Action, AllPlusSet, AllSet, BadQuery, Cache, Change, Codename, Content, CoreMigration, Diff, DirectorRegister, Error, Format, Mailer, Migration, Name, NotFound, Oops, PermissionDenied, Query, Reference, RightSet, RstarSet, SelfSet, SetPattern, StageDirector, StageSubdirector, StarSet, Subcards, SubdirectorArray, Success, TypePlusRightSet, TypeSet, ViewName

Constant Summary collapse

TRACKED_FIELDS =
%w(name type_id db_content trash).freeze
@@set_patterns =
[]
@@error_codes =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#follower_stashObject

Returns the value of attribute follower_stash.



62
63
64
# File 'lib/card.rb', line 62

def follower_stash
  @follower_stash
end

Class Method Details

.configObject



8
9
10
# File 'lib/card/loader.rb', line 8

def config
  Cardio.config
end

.const_missing(const) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/card/codename.rb', line 65

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

.new_director(card, opts = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/card/director_register.rb', line 19

def self.new_director card, opts={}
  if opts[:parent]
    StageSubdirector.new card, opts
  elsif DirectorRegister.act_card &&
        DirectorRegister.act_card != card &&
        DirectorRegister.act_card.director.running?
    DirectorRegister.act_card.director.subdirectors.add(card)
  else
    StageDirector.new card
  end
end

.pathsObject



12
13
14
# File 'lib/card/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

Instance Method Details

#act(opts = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/card/director_register.rb', line 2

def act opts={}
  if !DirectorRegister.act_card
    DirectorRegister.clear
    self.director = nil
    DirectorRegister.act_card = self
    main_act_block = true
    if opts[:success]
      Env[:success] = Success.new(cardname, Env.params[:success])
    end
  else
    main_act_block = false
  end
  yield
ensure
  DirectorRegister.clear if main_act_block
end

#expire_subcardsObject



17
18
19
# File 'lib/card/subcards.rb', line 17

def expire_subcards
  subcards.clear
end

#left_id=(card_or_id) ⇒ Object



258
259
260
# File 'lib/card/subcards.rb', line 258

def left_id= card_or_id
  write_card_or_id :left_id, card_or_id
end

#right_id=(card_or_id) ⇒ Object



254
255
256
# File 'lib/card/subcards.rb', line 254

def right_id= card_or_id
  write_card_or_id :right_id, card_or_id
end

#subcardsObject



12
13
14
15
# File 'lib/card/subcards.rb', line 12

def subcards
  @subcards ||= Subcards.new(self)
  # @subcards ||= (director && director.subcards)
end

#type_id=(card_or_id) ⇒ Object



262
263
264
# File 'lib/card/subcards.rb', line 262

def type_id= card_or_id
  write_card_or_id :type_id, card_or_id
end

#with_id_when_exists(card, &block) ⇒ Object



283
284
285
# File 'lib/card/subcards.rb', line 283

def with_id_when_exists card, &block
  card.director.call_after_store(&block)
end

#write_card_or_id(attribute, card_or_id) ⇒ Object



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/card/subcards.rb', line 266

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