Class: CleverSDK::Data::Tokens
- Inherits:
-
Object
- Object
- CleverSDK::Data::Tokens
- Includes:
- Enumerable
- Defined in:
- lib/clever_sdk/data/tokens.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
private.
Instance Method Summary collapse
- #data ⇒ Object
- #each(&block) ⇒ Object (also: #all)
-
#initialize(response) ⇒ Tokens
constructor
private.
- #inspect ⇒ Object
Constructor Details
#initialize(response) ⇒ Tokens
private
14 15 16 |
# File 'lib/clever_sdk/data/tokens.rb', line 14 def initialize(response) @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
private
11 12 13 |
# File 'lib/clever_sdk/data/tokens.rb', line 11 def response @response end |
Instance Method Details
#data ⇒ Object
18 19 20 |
# File 'lib/clever_sdk/data/tokens.rb', line 18 def data @data ||= Array(response.body.dig("data")) end |
#each(&block) ⇒ Object Also known as: all
22 23 24 25 26 27 |
# File 'lib/clever_sdk/data/tokens.rb', line 22 def each &block return enum_for :each unless block tokens = Array(data).lazy.map { |datum| CleverSDK::Data::Token.new(datum, response) } tokens.each(&block) end |
#inspect ⇒ Object
30 31 32 |
# File 'lib/clever_sdk/data/tokens.rb', line 30 def inspect "#<#{self.class.name}:0x#{(object_id * 2).to_s(16).rjust(16, "0")} tokens:#{data.count}>" end |