Sha256: 254d353f1e80a64fa08a81ecc11fb3961cb58d709e50858f235100ce4b916467

Contents?: true

Size: 859 Bytes

Versions: 2

Compression:

Stored size: 859 Bytes

Contents

module Granite
  module Form
    module Model
      module Associations
        module Collection
          class Proxy
            include Enumerable

            delegate :target, :loaded?, :reload, :clear, :concat, to: :@association
            delegate :each, :size, :length, :first, :last, :empty?, :many?, :==, :dup, to: :target
            alias << concat
            alias push concat

            def initialize(association)
              @association = association
            end

            def to_ary
              dup
            end

            alias to_a to_ary

            def inspect
              entries = target.take(10).map!(&:inspect)
              entries[10] = '...' if target.size > 10

              "#<#{self.class.name.demodulize} [#{entries.join(', ')}]>"
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
granite-form-0.6.1 lib/granite/form/model/associations/collection/proxy.rb
granite-form-0.6.0 lib/granite/form/model/associations/collection/proxy.rb