class MailchimpAPI::CollectionParsers::Base
Attributes
links[RW]
total_items[RW]
Public Class Methods
new(response = {})
click to toggle source
# File lib/mailchimp_api/collection_parsers/base.rb, line 7 def initialize(response = {}) @links = instantiate_links response.delete '_links' @total_items = response.delete 'total_items' @elements = response[element_key] || [] end
Protected Instance Methods
element_key()
click to toggle source
# File lib/mailchimp_api/collection_parsers/base.rb, line 16 def element_key self.class.name.demodulize.underscore.pluralize end
instantiate_links(links)
click to toggle source
# File lib/mailchimp_api/collection_parsers/base.rb, line 20 def instantiate_links(links) links&.map do |link| MailchimpAPI::Link.new link end end