Module: Tr3llo::Entities

Extended by:
Entities
Included in:
Entities
Defined in:
lib/3llo/entities.rb

Defined Under Namespace

Classes: Board, Card, Checklist, Comment, Label, List, User

Constant Summary collapse

SHORTCUT_PREFIX =
"#".freeze
InvalidKeyError =
Class.new(ArgumentError)
InvalidIDError =
Class.new(ArgumentError)

Instance Method Summary collapse

Instance Method Details

#make_shortcut(type, id) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/3llo/entities.rb', line 29

def make_shortcut(type, id)
  if id.is_a?(String)
    registry.register(type, id)
  else
    raise ArgumentError.new("Invalid ID")
  end
end

#parse_id(type, key) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/3llo/entities.rb', line 19

def parse_id(type, key)
  if key.start_with?(SHORTCUT_PREFIX)
    shortcut = key.delete_prefix(SHORTCUT_PREFIX)

    registry.reverse_lookup(type, shortcut)
  else
    key
  end
end