Module: Card::Set

Included in:
Abstract::Attachment, Abstract::Permission, All::Account, All::Actions, All::ActiveCard, All::AllCss, All::AllCsv, All::AllJs, All::Base, All::Bootstrap::Form, All::Bootstrap::Helper, All::Bootstrap::Wrapper, All::Collection, All::Comment, All::Content, All::ContentHistory, All::EmailHtml, All::EmailText, All::Erb, All::Error, All::EventViz, All::Fetch, All::File, All::Follow, All::Haml, All::History, All::Initialize, All::Json, All::Links, All::Name, All::Notify, All::Observer, All::Pattern, All::Permissions, All::Phases, All::References, All::RichBootstrap, All::RichHtml::Content, All::RichHtml::Editing, All::RichHtml::Form, All::RichHtml::Header, All::RichHtml::Menu, All::RichHtml::Modal, All::RichHtml::Toolbar, All::RichHtml::Wrapper, All::Rss, All::Rules, All::States, All::Templating, All::Text, All::TrackedAttributes, All::Trash, All::Type, All::Utils, All::ViewCache, Right::Account, Right::AddHelp, Right::Bcc, Right::Cc, Right::Comment, Right::Create, Right::Default, Right::Delete, Right::Discussion, Right::Email, Right::Follow, Right::FollowFields, Right::Followers, Right::Following, Right::From, Right::Help, Right::HtmlMessage, Right::MachineInput, Right::MachineOutput, Right::Password, Right::Read, Right::Salt, Right::Script, Right::Stats, Right::Status, Right::Structure, Right::Style, Right::To, Right::Token, Right::Update, Right::WhenCreated, Right::WhenLastEdited, Rstar::Rules, Self::AccountLinks, Self::Accountable, Self::AddHelp, Self::Alerts, Self::All, Self::Always, Self::Autoname, Self::BootstrapCards, Self::BootstrapJs, Self::BootswatchShared, Self::Captcha, Self::Create, Self::Created, Self::Default, Self::Delete, Self::Edited, Self::Follow, Self::FollowDefaults, Self::Foot, Self::Head, Self::Help, Self::Input, Self::Layout, Self::Navbox, Self::Never, Self::Now, Self::OnCreate, Self::OnDelete, Self::OnUpdate, Self::Options, Self::OptionsLabel, Self::PerformanceLog, Self::Read, Self::Recent, Self::RecentSettings, Self::Script, Self::ScriptAce, Self::ScriptCardMenu, Self::ScriptHtml5shivPrintshiv, Self::ScriptJquery, Self::ScriptJqueryHelper, Self::ScriptSlot, Self::ScriptTinymce, Self::Search, Self::Signin, Self::SmartmenuCss, Self::SmartmenuJs, Self::Stats, Self::Structure, Self::Style, Self::StyleBootstrapCompatible, Self::StyleCards, Self::StyleJqueryUiSmoothness, Self::TableOfContents, Self::Thanks, Self::Update, Self::Version, Type::Basic, Type::Cardtype, Type::CoffeeScript, Type::Css, Type::Date, Type::EmailTemplate, Type::File, Type::Html, Type::Image, Type::JavaScript, Type::LayoutType, Type::Number, Type::Phrase, Type::PlainText, Type::Pointer, Type::Scss, Type::SearchType, Type::Session, Type::Set, Type::Setting, Type::Signup, Type::Skin, Type::Toggle, Type::Uri, Type::User, TypePlusRight::User::Follow
Defined in:
lib/card/set.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

remove_const :Set if const_defined?(:Set, false)

Defined Under Namespace

Modules: Abstract, All, Format, Right, Rstar, Self, Type, TypePlusRight

Constant Summary collapse

@@modules =
{ base: [], base_format: {}, nonbase: {}, nonbase_format: {} }

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.clean_empty_module_from_hash(hash) ⇒ Object



371
372
373
374
375
376
# File 'lib/card/set.rb', line 371

def clean_empty_module_from_hash hash
  hash.each do |mod_name, modlist|
    modlist.delete_if { |x| x.instance_methods.empty? }
    hash.delete mod_name if modlist.empty?
  end
end

.clean_empty_modulesObject



364
365
366
367
368
369
# File 'lib/card/set.rb', line 364

def clean_empty_modules
  clean_empty_module_from_hash modules[:nonbase]
  modules[:nonbase_format].values.each do |hash|
    clean_empty_module_from_hash hash
  end
end

.extended(mod) ⇒ Object

each set file calls ‘extend Card::Set` when loaded



302
303
304
# File 'lib/card/set.rb', line 302

def extended mod
  register_set mod
end

.process_base_module_list(list, klass) ⇒ Object



353
354
355
356
357
358
359
360
361
362
# File 'lib/card/set.rb', line 353

def process_base_module_list list, klass
  list.each do |mod|
    if mod.instance_methods.any?
      klass.send :include, mod
    end
    if (class_methods = mod.const_get_if_defined(:ClassMethods))
      klass.send :extend, class_methods
    end
  end
end

.process_base_modulesObject

‘base modules’ are modules that are permanently included on the Card or Format class ‘nonbase modules’ are included dynamically on singleton_classes



344
345
346
347
348
349
350
351
# File 'lib/card/set.rb', line 344

def process_base_modules
  process_base_module_list modules[:base], Card
  modules[:base_format].each do |format_class, modules_list|
    process_base_module_list modules_list, format_class
  end
  modules.delete :base
  modules.delete :base_format
end

.register_set(set_module) ⇒ Object

make the set available for use



307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/card/set.rb', line 307

def register_set set_module
  return if set_module.abstract_set?  # noop; only used by explicit
  # inclusion in other set modules
  if set_module.all_set?
    # automatically included in Card class
    modules[:base] << set_module
  else
    # made ready for dynamic loading via #include_set_modules
    modules[:nonbase][set_module.shortname] ||= []
    modules[:nonbase][set_module.shortname] << set_module
  end
end

.write_tmp_file(from_file, to_file, rel_path) ⇒ Object



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/card/set.rb', line 320

def write_tmp_file from_file, to_file, rel_path
  name_parts = rel_path.gsub(/\.rb/, '').split(File::SEPARATOR)
  submodules = name_parts.map { |a| "module #{a.camelize};" } * ' '
  file_content = <<EOF
# -*- encoding : utf-8 -*-
class Card; module Set; #{submodules} extend Card::Set
# ~~~~~~~~~~~ above autogenerated; below pulled from #{from_file} ~~~~~~~~~~~
#{ File.read from_file }

# ~~~~~~~~~~~ below autogenerated; above pulled from #{from_file} ~~~~~~~~~~~
end;end;#{'end;' * name_parts.size}
EOF

  FileUtils.mkdir_p File.dirname(to_file)
  File.write to_file, file_content
  to_file
end

Instance Method Details

#abstract_set?Boolean

Returns:

  • (Boolean)


404
405
406
# File 'lib/card/set.rb', line 404

def abstract_set?
  name =~ /^Card::Set::Abstract::/
end

#all_set?Boolean

Returns:

  • (Boolean)


408
409
410
# File 'lib/card/set.rb', line 408

def all_set?
  name =~ /^Card::Set::All::/
end

#card_accessor(*args) ⇒ Object

ActiveCard support: accessing plus cards as attributes



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

def card_accessor *args
  options = args.extract_options!
  add_traits args, options.merge(reader: true, writer: true)
end

#card_reader(*args) ⇒ Object



263
264
265
266
# File 'lib/card/set.rb', line 263

def card_reader *args
  options = args.extract_options!
  add_traits args, options.merge(reader: true)
end

#card_writer(*args) ⇒ Object



268
269
270
271
# File 'lib/card/set.rb', line 268

def card_writer *args
  options = args.extract_options!
  add_traits args, options.merge(writer: true)
end

#define_active_job(name, final_method, queue = :default) ⇒ Object

creates an Active Job. The scheduled job gets the card object as argument and all serializable attributes of the card. (when the job is executed ActiveJob fetches the card from the database so

all attributes get lost)

Parameters:

  • name (String)

    the name for the ActiveJob child class

  • final_method (String)

    the name of the card instance method to be queued

  • queue (Hash) (defaults to: :default)

    a customizable set of options

Options Hash (queue):

  • (:default) (Symbol)

    the name of the queue



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/card/set.rb', line 235

def define_active_job name, final_method, queue=:default
  class_name = name.to_s.camelize
  eval %{
    class ::#{class_name} < ActiveJob::Base
      queue_as #{queue}
    end
  }
  Object.const_get(class_name).class_eval do
    define_method :perform, proc { |card, attributes|
      attributes.each do |name, args|
        # symbols are not allowed so all symbols arrive here as strings
        # convert strings that were symbols before back to symbols
        value = args[:symbol] ? args[:value].to_sym : args[:value]
        card.instance_variable_set("@#{name}", value)
      end
      card.send final_method
    }
  end
end

#define_event_method(event, call_method, _opts) ⇒ Object



215
216
217
218
219
220
221
222
223
224
225
# File 'lib/card/set.rb', line 215

def define_event_method event, call_method, _opts
  class_eval do
    define_method event do
      # Rails.logger.rspec event
      # puts "#{self.name}: #{event}"
      run_callbacks event do
        send call_method
      end
    end
  end
end

#define_event_perform_later_method(event, method_name) ⇒ Object



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/card/set.rb', line 196

def define_event_perform_later_method event, method_name
  class_eval do
    define_method method_name, proc {
      s_attr =
        serializable_attributes.each_with_object({}) do |name, hash|
          value = instance_variable_get("@#{name}")
          hash[name] =
            # ActiveJob doesn't accept symbols as arguments
            if Symbol === value
              { value: value.to_s, symbol: true }
            else
              { value: value }
            end
        end
      Object.const_get(event.to_s.camelize).perform_later(self, s_attr)
    }
  end
end

#define_on_format(format_name = :base, &block) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/card/set.rb', line 130

def define_on_format format_name=:base, &block
  # format class name, eg. HtmlFormat
  klass = Card::Format.format_class_name format_name
  # called on current set module, eg Card::Set::Type::Pointer
  mod = const_get_or_set klass do
    # yielding set format module, eg Card::Set::Type::Pointer::HtmlFormat
    m = Module.new
    register_set_format Card.const_get(klass), m
    m.extend Card::Set::Format
    m
  end
  mod.class_eval &block
end

#ensure_set(&block) ⇒ Object



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/card/set.rb', line 273

def ensure_set &block
  begin
    set_module = block.call
  rescue NameError => e
    if e.message.match /uninitialized constant (?:Card::Set::)?(.+)$/
      $1.split('::').inject(Card::Set) do |set_mod, module_name|
        set_mod.const_get_or_set module_name do
          Module.new
        end
      end
    end
    # try again - there might be another submodule that doesn't exist
    ensure_set &block
  else
    set_module.extend Card::Set
  end
end

#event(event, opts = {}, &final) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/card/set.rb', line 150

def event event, opts={}, &final
  perform_later = (opts[:before] == :subsequent) ||
                  (opts[:after] == :subsequent)
  final_method = "#{event}_without_callbacks" # should be private?
  opts[:on] = [:create, :update] if opts[:on] == :save

  Card.define_callbacks event

  class_eval do
    define_method final_method, &final
  end

  if perform_later
    defer_method = "#{event}_perform_later"
    define_event_perform_later_method event, defer_method
    define_active_job event, final_method, opts[:queue_as]
    define_event_method event, defer_method, opts
  else
    define_event_method event, final_method, opts
  end
  set_event_callbacks event, opts
end

#format(*format_names, &block) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
# File 'lib/card/set.rb', line 118

def format *format_names, &block
  if format_names.empty?
    format_names = [:base]
  elsif format_names.first == :all
    format_names = Card::Format.registered
      .reject { |f| Card::Format.aliases[f] }
  end
  format_names.each do |f|
    define_on_format f, &block
  end
end

#phase_method(method, opts = {}, &block) ⇒ Object



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/card/set.rb', line 173

def phase_method method, opts={}, &block
  class_eval do
    define_method "_#{method}", &block
    define_method method do |*args|
      error =
        if !phase_ok? opts
          if !phase
            "phase method #{method} called outside of event phases"
          else
            "#{opts.inspect} method #{method} called in phase #{phase}"
          end
        elsif !on_condition_applies?(opts[:on])
          "on: #{opts[:on]} method #{method} called on #{@action}"
        end
      if error
        raise Card::Error, error
      else
        send "_#{method}", *args
      end
    end
  end
end

#register_set_format(format_class, mod) ⇒ Object



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/card/set.rb', line 379

def register_set_format format_class, mod
  return if self.abstract_set? # noop; only used by explicit inclusion in
  # other set modules

  if self.all_set?
    # ready to include in base format classes
    modules[:base_format][format_class] ||= []
    modules[:base_format][format_class] << mod
  else
    # ready to include dynamically in set members' format singletons
    format_hash = modules[:nonbase_format][format_class] ||= {}
    format_hash[shortname] ||= []
    format_hash[shortname] << mod
  end
end

#shortnameObject



395
396
397
398
399
400
401
402
# File 'lib/card/set.rb', line 395

def shortname
  parts = name.split '::'
  first = 2 # shortname eliminates Card::Set
  set_class = Card::SetPattern.find parts[first].underscore

  last = first + set_class.anchor_parts_count
  parts[first..last].join '::'
end

#view(*args, &block) ⇒ Object



144
145
146
147
148
# File 'lib/card/set.rb', line 144

def view *args, &block
  format do
    view *args, &block
  end
end