Sha256: ebcc379e1932ab695116339fb4b1ec67e7e3de81e0263da174bf1442195afc5f
Contents?: true
Size: 913 Bytes
Versions: 5
Compression:
Stored size: 913 Bytes
Contents
require 'fin/changed_list' module Fin # Represents Container that holds Model objects (items) of only ONE specific type # TODO: In future, merge ChangedList and ContainerList to flatten class hierarchy class ContainerList < ChangedList attr_reader :item_type def initialize opts = {} @item_type = opts[:item_type] raise "Item type not given for #{self}" unless @item_type super() end def check item item.is_a?(@item_type) && item.index end def index item item.index if check item end def add_record rec add? @item_type.from_record rec end def remove_record rec, id index = @item_type.index_for rec remove? self[index] end def add_message msg add? @item_type.from_msg msg end def remove_message msg, id item = @item_type.from_msg msg remove? self[item.index] end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
fin-0.1.6 | lib/fin/container_list.rb |
fin-0.1.5 | lib/fin/container_list.rb |
fin-0.1.4 | lib/fin/container_list.rb |
fin-0.1.3 | lib/fin/container_list.rb |
fin-0.1.2 | lib/fin/container_list.rb |