Class: Uphold::Entities::BaseEntity

Inherits:
Object
  • Object
show all
Defined in:
lib/uphold/entities/base_entity.rb

Defined Under Namespace

Classes: PaginatedCollection

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ BaseEntity

Returns a new instance of BaseEntity.



13
14
15
# File 'lib/uphold/entities/base_entity.rb', line 13

def initialize(attributes = {})
  super(Uphold::Helpers.underscored_hash(attributes))
end

Class Method Details

.from_collection(entities, content_range) ⇒ Object



6
7
8
9
10
11
# File 'lib/uphold/entities/base_entity.rb', line 6

def self.from_collection(entities, content_range)
  total_size = (content_range && content_range.split('/')[1]) || entities.size
  items = entities.map { |entity| new(entity.to_h) }

  PaginatedCollection.new(items, total_size)
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/uphold/entities/base_entity.rb', line 17

def error?
  is_a?(Uphold::Entities::Error)
end