Sha256: 73b712dd9f1b13e146b50d5fc65dcc52b97f561076902cc10c0be98071d36823
Contents?: true
Size: 794 Bytes
Versions: 2
Compression:
Stored size: 794 Bytes
Contents
module Paid class APIList < APIClass include Enumerable attribute :object attribute :data def [](k) data[k] end def []=(k, v) data[k]=v end def last data.last end def length data.length end def each(&blk) data.each(&blk) end def self.constructor(klass) lambda do |json| instance = self.new instance.json = json json.each do |k, v| if attribute_names.include?(k.to_sym) if k.to_sym == :data instance.send("#{k}=", v.map{ |i| klass.construct(i) }) else instance.send("#{k}=", v) end end end instance.clear_changed_attributes instance end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
paid-1.0.1 | lib/paid/api_list.rb |
paid-1.0.0 | lib/paid/api_list.rb |