Module: Card::Env::Success::Target

Included in:
Card::Env::Success
Defined in:
lib/card/env/success/target.rb

Overview

The success “target” is the destination upon success.

@card, @name, @id, etc all refer to the target card

Instance Method Summary collapse

Instance Method Details

#card(name_context = @name_context) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/card/env/success/target.rb', line 49

def card name_context=@name_context
  if @card
    @card
  elsif @id
    Card.fetch @id
  elsif @name
    Card.fetch @name.to_name.absolute(name_context), new: @new_args
  end
end

#content=(content) ⇒ Object



45
46
47
# File 'lib/card/env/success/target.rb', line 45

def content= content
  @new_args[:content] = content
end

#id=(id) ⇒ Object

Deprecated.


31
32
33
34
35
# File 'lib/card/env/success/target.rb', line 31

def id= id
  # for backwards compatibility use mark here.
  # id was often used for the card name
  self.mark = id
end

#mark=(value) ⇒ Object

TODO: refactor to use cardish



20
21
22
23
24
25
26
27
28
# File 'lib/card/env/success/target.rb', line 20

def mark= value
  case value
  when Integer then @id = value
  when String then @name = value
  when Card then @card = value
  else
    self.target = value
  end
end

#target(name_context = @name_context) ⇒ Object



13
14
15
16
17
# File 'lib/card/env/success/target.rb', line 13

def target name_context=@name_context
  card(name_context) ||
    (@target == :previous ? Card::Env.previous_location : @target) ||
    Card.fetch(name_context)
end

#target=(value) ⇒ Object



8
9
10
11
# File 'lib/card/env/success/target.rb', line 8

def target= value
  @id = @name = @card = nil
  @target = process_target value
end

#type=(type) ⇒ Object



37
38
39
# File 'lib/card/env/success/target.rb', line 37

def type= type
  @new_args[:type] = type
end

#type_id=(type_id) ⇒ Object



41
42
43
# File 'lib/card/env/success/target.rb', line 41

def type_id= type_id
  @new_args[:type_id] = type_id.to_i
end