Class: FieldView::ListObject
- Inherits:
-
Requestable
- Object
- Requestable
- FieldView::ListObject
- Includes:
- Enumerable
- Defined in:
- lib/fieldview/list_object.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#last_http_status ⇒ Object
readonly
Returns the value of attribute last_http_status.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#listable ⇒ Object
readonly
Returns the value of attribute listable.
-
#next_token ⇒ Object
readonly
Returns the value of attribute next_token.
Attributes inherited from Requestable
Instance Method Summary collapse
- #each(&blk) ⇒ Object
-
#has_more? ⇒ Boolean
alias for more_pages.
-
#initialize(listable, auth_token, data, http_status, next_token: nil, limit: 100) ⇒ ListObject
constructor
A new instance of ListObject.
- #more_pages? ⇒ Boolean
- #next_page! ⇒ Object
- #restart! ⇒ Object
Constructor Details
#initialize(listable, auth_token, data, http_status, next_token: nil, limit: 100) ⇒ ListObject
Returns a new instance of ListObject.
7 8 9 10 11 12 13 14 |
# File 'lib/fieldview/list_object.rb', line 7 def initialize(listable, auth_token, data, http_status, next_token: nil, limit: 100) @listable = listable @data = data @last_http_status = http_status @next_token = next_token @limit = limit super(auth_token) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/fieldview/list_object.rb', line 4 def data @data end |
#last_http_status ⇒ Object (readonly)
Returns the value of attribute last_http_status.
4 5 6 |
# File 'lib/fieldview/list_object.rb', line 4 def last_http_status @last_http_status end |
#limit ⇒ Object
Returns the value of attribute limit.
3 4 5 |
# File 'lib/fieldview/list_object.rb', line 3 def limit @limit end |
#listable ⇒ Object (readonly)
Returns the value of attribute listable.
4 5 6 |
# File 'lib/fieldview/list_object.rb', line 4 def listable @listable end |
#next_token ⇒ Object (readonly)
Returns the value of attribute next_token.
4 5 6 |
# File 'lib/fieldview/list_object.rb', line 4 def next_token @next_token end |
Instance Method Details
#each(&blk) ⇒ Object
16 17 18 |
# File 'lib/fieldview/list_object.rb', line 16 def each(&blk) self.data.each(&blk) end |
#has_more? ⇒ Boolean
alias for more_pages
28 29 30 |
# File 'lib/fieldview/list_object.rb', line 28 def has_more?() return self.more_pages?() end |
#more_pages? ⇒ Boolean
32 33 34 |
# File 'lib/fieldview/list_object.rb', line 32 def more_pages?() return Util.http_status_is_more_in_list?(self.last_http_status) end |
#next_page! ⇒ Object
20 21 22 23 24 25 |
# File 'lib/fieldview/list_object.rb', line 20 def next_page!() return if !self.more_pages?() new_list = @listable.list(auth_token, limit: self.limit, next_token: self.next_token) initialize(new_list.listable, new_list.auth_token, new_list.data, new_list.last_http_status, next_token: new_list.next_token, limit: new_list.limit) end |
#restart! ⇒ Object
36 37 38 39 40 |
# File 'lib/fieldview/list_object.rb', line 36 def restart!() @last_http_status = nil @next_token = nil next_page!() end |