Sha256: 2f5450eee33c59f122a6ce9ba6b3f56973c734dc71e4769e230b5d0ad78fae2c

Contents?: true

Size: 889 Bytes

Versions: 3

Compression:

Stored size: 889 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_method :<<, :concat
            alias_method :push, :concat

            def initialize(association)
              @association = association
            end

            def to_ary
              dup
            end

            alias_method :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

3 entries across 3 versions & 1 rubygems

Version Path
granite-form-0.5.0 lib/granite/form/model/associations/collection/proxy.rb
granite-form-0.4.0 lib/granite/form/model/associations/collection/proxy.rb
granite-form-0.3.0 lib/granite/form/model/associations/collection/proxy.rb