Class: ChgkRating::ChgkObject

Inherits:
Object
  • Object
show all
Defined in:
lib/chgk_rating/chgk_object.rb

Direct Known Subclasses

ChgkRating::Collections::Base, Models::Base

Instance Method Summary collapse

Instance Method Details

#build_model(object, klass = ChgkRating::Models::Team, params = {lazy: true}) ⇒ Object


3
4
5
6
# File 'lib/chgk_rating/chgk_object.rb', line 3

def build_model(object, klass = ChgkRating::Models::Team, params = {lazy: true})
  return unless object
  object.instance_of?(klass) ? object : klass.new(object, params)
end

#extract_id_from(obj, klass = ChgkRating::Models::Team) ⇒ Object


8
9
10
11
# File 'lib/chgk_rating/chgk_object.rb', line 8

def extract_id_from(obj, klass = ChgkRating::Models::Team)
  return obj unless obj.is_a? klass
  obj&.id
end