Module: Card::Director::CardClass
- Included in:
- Card
- Defined in:
- card/lib/card/director/card_class.rb
Overview
director-related Card class methods
Instance Method Summary collapse
-
#create(opts) ⇒ Object
-
#create!(opts) ⇒ Object
-
#ensure(opts) ⇒ Object
If the conflict setting is “defer”:.
-
#ensure!(opts) ⇒ Object
Instance Method Details
#create(opts) ⇒ Object
11 12 13 14 15 |
# File 'card/lib/card/director/card_class.rb', line 11 def create opts card = new opts card.save card end |
#create!(opts) ⇒ Object
5 6 7 8 9 |
# File 'card/lib/card/director/card_class.rb', line 5 def create! opts card = new opts card.save! card end |
#ensure(opts) ⇒ Object
If the conflict setting is “defer”:
- if the codename is NOT already in use, we create a new card with an altered name
- otherwise we do nothing.
If the conflict setting is “default”: - if the codename is NOT already in use: - if the card using the name we want is pristine, we update that card - otherwise we create a new card with an altered name - if the _codename IS already in use - if the card with the codename is pristine, we update everything but the name (which is used by another card) - otherwise we do nothing
If the conflict setting is “override”: - if the _codename is NOT already in use, we update the existing card with the name. - otherwise we alter the card withe the conflicting name and update the card with the codename.
51 52 53 |
# File 'card/lib/card/director/card_class.rb', line 51 def ensure opts ensuring opts, &:save_if_needed end |
#ensure!(opts) ⇒ Object
55 56 57 |
# File 'card/lib/card/director/card_class.rb', line 55 def ensure! opts ensuring opts, &:save_if_needed! end |