Module: Card::Format::Nest::Fetch

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

Overview

Fetch card for a nest

Instance Method Summary collapse

Instance Method Details

#fetch_nested_card(name_or_card_or_opts, opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/card/format/nest/fetch.rb', line 6

def fetch_nested_card name_or_card_or_opts, opts={}
  case name_or_card_or_opts
  when Card
    name_or_card_or_opts
  when Hash
    opts = name_or_card_or_opts
    Card.fetch(opts[:inc_name], new: nest_new_args(opts))
  when Symbol
    Card.fetch(name_or_card_or_opts)
  else
    opts[:inc_name] = name_or_card_or_opts.to_s
    Card.fetch name_or_card_or_opts, new: nest_new_args(opts)
  end
end