Module: Card::Set
- Includes:
- AdvancedApi, Event::Api, Format, Helpers, Inheritance, Trait
- Defined in:
- lib/card/set.rb,
lib/card/set/type.rb,
lib/card/set/event.rb,
lib/card/set/trait.rb,
lib/card/set/format.rb,
lib/card/set/helpers.rb,
lib/card/set/pattern.rb,
lib/card/set/abstract.rb,
lib/card/set/event/all.rb,
lib/card/set/registrar.rb,
lib/card/set/i18n_scope.rb,
lib/card/set/inheritance.rb,
lib/card/set/pattern/all.rb,
lib/card/set/advanced_api.rb,
lib/card/set/card_methods.rb,
lib/card/set/i18n_scanner.rb,
lib/card/set/pattern/base.rb,
lib/card/set/event/options.rb,
lib/card/set/required_field.rb,
lib/card/set/event/callbacks.rb,
lib/card/set/format/haml_paths.rb,
lib/card/set/event/delayed_event.rb,
lib/card/set/pattern/class_methods.rb,
lib/card/set/event/skip_and_trigger.rb,
lib/card/set/format/abstract_format.rb,
lib/card/set/format/abstract_format/wrapper.rb,
lib/card/set/format/abstract_format/view_opts.rb,
lib/card/set/format/abstract_format/haml_views.rb,
lib/card/set/format/abstract_format/view_definition.rb
Overview
A Set is a group of Cards to which Rules may apply. Sets can be as specific as a single card, as general as all cards, or anywhere in between.
Rules can defined onto Sets in two ways:
- **Card rules** are defined in card content. These are generally configured via the
web interface and are thus documented at decko.org/rules.
- **Code rules** can be defined in a 'set module'.
The Cardio::Mod docs explain how to create mods and set_modules. This page explains how those modules become useful.
Suppose you have created a “mod” for managing your contacts called “contactmanager”, and it includes code that would apply to all +address cards here:
./contactmanager/set/right/address.rb
Then, whenever you fetch or instantiate a +address card, the card will automatically include code from that set module. In fact, it will include all the set modules associated with sets of which it is a member.
For example, say you have a Plaintext card named 'Philipp+address', and you have set
files for the following sets:
* all cards
* all Plaintext cards
* all cards ending in +address
When you run this:
mycard = Card.fetch 'Philipp+address'
...then mycard will include the set modules associated with each of those sets in the
above order.
Note that the set module's filename connects it to the set, so both the set_pattern
and the set_anchor must correspond to the codename of a card in the database to function correctly.
A set module is "just ruby", but is generally quite concise because Card uses
a) the set module's file location to autogenerate ruby module names and
b) Card::Set to provide API for the most common set methods.
Defined Under Namespace
Modules: AdvancedApi, CardMethods, Format, Helpers, I18nScope, Inheritance, Pattern, Registrar, Trait Classes: Abstract, Event, I18nScanner, RequiredField, Type
Constant Summary
Constants included from Helpers
Helpers::SET_PATTERN_TEST_REGEXP
Constants included from Event::Api
Class Attribute Summary collapse
-
.basket ⇒ Object
Returns the value of attribute basket.
-
.modules ⇒ Object
Returns the value of attribute modules.
-
.traits ⇒ Object
Returns the value of attribute traits.
Class Method Summary collapse
Methods included from I18nScope
Methods included from Registrar
extended, finalize_load, process_base_modules, register_set
Methods included from Helpers
#format_module, #format_modules, #method_missing, #modules, #num_set_parts, #pattern_code, #respond_to_missing?, #set_format_type_key, #set_name_parts, #set_type_key, #shortname, #test_set, #underscore
Methods included from AdvancedApi
#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
Methods included from Inheritance
#include_set, #include_set_formats
Methods included from Trait
#card_accessor, #card_reader, #card_writer, #require_field
Methods included from Event::Api
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Card::Set::Helpers
Class Attribute Details
.basket ⇒ Object
Returns the value of attribute basket.
61 62 63 |
# File 'lib/card/set.rb', line 61 def basket @basket end |
.modules ⇒ Object
Returns the value of attribute modules.
61 62 63 |
# File 'lib/card/set.rb', line 61 def modules @modules end |
.traits ⇒ Object
Returns the value of attribute traits.
61 62 63 |
# File 'lib/card/set.rb', line 61 def traits @traits end |
Class Method Details
.reset ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/card/set.rb', line 63 def reset self.modules = { base: [], base_format: {}, nonbase: {}, nonbase_format: {}, abstract: {}, abstract_format: {} } self.basket = {} end |