Class: StripeMock::Data::List
- Inherits:
-
Object
- Object
- StripeMock::Data::List
- Defined in:
- lib/stripe_mock/data/list.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#ending_before ⇒ Object
readonly
Returns the value of attribute ending_before.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#starting_after ⇒ Object
readonly
Returns the value of attribute starting_after.
Instance Method Summary collapse
- #has_more? ⇒ Boolean
-
#initialize(data, options = {}) ⇒ List
constructor
A new instance of List.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to?(method_name, priv = false) ⇒ Boolean
- #to_hash ⇒ Object (also: #to_h)
- #url ⇒ Object
Constructor Details
#initialize(data, options = {}) ⇒ List
Returns a new instance of List.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/stripe_mock/data/list.rb', line 6 def initialize(data, = {}) @data = Array(data.clone) @limit = [[[:limit] || 10, 100].min, 1].max # restrict @limit to 1..100 @starting_after = [:starting_after] @ending_before = [:ending_before] @active = [:active] if contains_stripe_objects? prune_deleted_data sort_data end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/stripe_mock/data/list.rb', line 31 def method_missing(method_name, *args, &block) hash = to_hash if hash.keys.include?(method_name) hash[method_name] else super end end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
4 5 6 |
# File 'lib/stripe_mock/data/list.rb', line 4 def active @active end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/stripe_mock/data/list.rb', line 4 def data @data end |
#ending_before ⇒ Object (readonly)
Returns the value of attribute ending_before.
4 5 6 |
# File 'lib/stripe_mock/data/list.rb', line 4 def ending_before @ending_before end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
4 5 6 |
# File 'lib/stripe_mock/data/list.rb', line 4 def limit @limit end |
#starting_after ⇒ Object (readonly)
Returns the value of attribute starting_after.
4 5 6 |
# File 'lib/stripe_mock/data/list.rb', line 4 def starting_after @starting_after end |
Instance Method Details
#has_more? ⇒ Boolean
27 28 29 |
# File 'lib/stripe_mock/data/list.rb', line 27 def has_more? (offset + limit) < data.size end |
#respond_to?(method_name, priv = false) ⇒ Boolean
41 42 43 |
# File 'lib/stripe_mock/data/list.rb', line 41 def respond_to?(method_name, priv = false) to_hash.keys.include?(method_name) || super end |
#to_hash ⇒ Object Also known as: to_h
22 23 24 |
# File 'lib/stripe_mock/data/list.rb', line 22 def to_hash { object: "list", data: data_page, url: url, has_more: has_more? } end |
#url ⇒ Object
18 19 20 |
# File 'lib/stripe_mock/data/list.rb', line 18 def url "/v1/#{object_types}" end |