Sha256: bb80d836a35f886bf255369968310850550be216e29d44ed786e4a7d994718f6

Contents?: true

Size: 904 Bytes

Versions: 3

Compression:

Stored size: 904 Bytes

Contents

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

            delegate :target, :save, :save!, :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.2.0 lib/granite/form/model/associations/collection/proxy.rb
granite-form-0.1.1 lib/granite/form/model/associations/collection/proxy.rb
granite-form-0.1.0 lib/granite/form/model/associations/collection/proxy.rb