Module: Card::Format::Nest::Subformat

Included in:
Card::Format::Nest
Defined in:
lib/card/format/nest/subformat.rb

Instance Method Summary collapse

Instance Method Details

#field_subformat(field) ⇒ Object



16
17
18
19
# File 'lib/card/format/nest/subformat.rb', line 16

def field_subformat field
  field = card.cardname.field(field) unless field.is_a?(Card)
  subformat field
end

#subformat(subcard) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/card/format/nest/subformat.rb', line 5

def subformat subcard
  subcard = Card.fetch(subcard, new: {}) if subcard.is_a?(String)
  self.class.new subcard,
                 parent: self, depth: @depth + 1, root: @root,
                 # FIXME: - the following four should not be hard-coded
                 # here.  need a generalized mechanism
                 # for attribute inheritance
                 context_names: @context_names, mode: @mode,
                 mainline: @mainline, form: @form
end