Sha256: 3d8d027174f2112c925e57eb3b82030b60ffc4967be8852e4f81ff4d1f6353e1
Contents?: true
Size: 727 Bytes
Versions: 4
Compression:
Stored size: 727 Bytes
Contents
# frozen_string_literal: true module IronBank # Collection class which allows records reloadable from the source class Collection include Enumerable extend Forwardable def_delegators :@records, :[], :each, :empty?, :length, :map, :size, :to_ary def initialize(klass, conditions, records) @klass = klass @conditions = conditions @records = records end # Update records from source def reload @records = @klass.where(@conditions) end # In case you need to access all array methods def to_a @records end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
iron_bank-5.4.1 | lib/iron_bank/collection.rb |
iron_bank-5.4.0 | lib/iron_bank/collection.rb |
iron_bank-5.3.2 | lib/iron_bank/collection.rb |
iron_bank-5.3.0 | lib/iron_bank/collection.rb |