Module: TelegramBot::AutoFromMethods::ClassMethods

Defined in:
lib/telegram_bot/auto_from_methods.rb

Instance Method Summary collapse

Instance Method Details

#extra_typesObject



19
20
21
# File 'lib/telegram_bot/auto_from_methods.rb', line 19

def extra_types
  {}
end

#from(id) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/telegram_bot/auto_from_methods.rb', line 4

def from(id)
  case id
  when self, Struct
    id
  when nil
    nil
  when Hash
    parse(id)
  when Integer
    new(id)
  else
    warn "unknown stuff passed in [#{id}]"
  end
end

#hash_key_aliasesObject



23
24
25
# File 'lib/telegram_bot/auto_from_methods.rb', line 23

def hash_key_aliases
  {}
end

#parse(hsh) ⇒ Object



27
28
29
30
31
# File 'lib/telegram_bot/auto_from_methods.rb', line 27

def parse(hsh)
  obj = new(*parse_attrs(hsh))
  parse_extra_types(obj)
  obj
end