Module: Card::Subcards::Relate

Included in:
Card::Subcards
Defined in:
card/lib/card/subcards/relate.rb

Overview

Methods for handling related subcards

Instance Method Summary collapse

Instance Method Details

#child(name) ⇒ Object



13
14
15
16
17
18
19
20
# File 'card/lib/card/subcards/relate.rb', line 13

def child name
  absolute_name = @context_card.name.field_name name
  if @keys.include? absolute_name.key
    absolute_name
  else
    relative_child name
  end
end

#field_name_to_key(name) ⇒ Object



5
6
7
8
9
10
11
# File 'card/lib/card/subcards/relate.rb', line 5

def field_name_to_key name
  if @context_card.name.starts_with_joint?
    relative_child(name).key
  else
    child(name).key
  end
end

#relative_child(name) ⇒ Object



22
23
24
# File 'card/lib/card/subcards/relate.rb', line 22

def relative_child name
  @context_card.name.relative_field_name name
end