Sha256: e580bd1c60ee419ff1d79089d7885560e822e9837197a9e5b1be921d09944aff

Contents?: true

Size: 763 Bytes

Versions: 56

Compression:

Stored size: 763 Bytes

Contents

module ActiveFedora
  module Delegation # :nodoc:
    extend ActiveSupport::Concern

    # This module creates compiled delegation methods dynamically at runtime, which makes
    # subsequent calls to that method faster by avoiding method_missing. The delegations
    # may vary depending on the klass of a relation, so we create a subclass of Relation
    # for each different klass, and the delegations are compiled into that subclass only.
    
    delegate :length, :collect, :map, :each, :all?, :include?, :to_ary, :to => :to_a


    def method_missing(method, *args, &block)
      if Array.method_defined?(method)
        self.class.delegate method, :to => :to_a
        to_a.send(method, *args, &block)
      else
        super
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
active-fedora-9.0.8 lib/active_fedora/relation/delegation.rb
active-fedora-8.7.0 lib/active_fedora/relation/delegation.rb
active-fedora-8.6.0 lib/active_fedora/relation/delegation.rb
active-fedora-8.5.0 lib/active_fedora/relation/delegation.rb
active-fedora-8.4.2 lib/active_fedora/relation/delegation.rb
active-fedora-8.4.1 lib/active_fedora/relation/delegation.rb
active-fedora-7.3.1 lib/active_fedora/relation/delegation.rb
active-fedora-7.3.0 lib/active_fedora/relation/delegation.rb
active-fedora-8.4.0 lib/active_fedora/relation/delegation.rb
active-fedora-8.3.0 lib/active_fedora/relation/delegation.rb
active-fedora-8.2.2 lib/active_fedora/relation/delegation.rb
active-fedora-8.2.1 lib/active_fedora/relation/delegation.rb
active-fedora-8.2.0 lib/active_fedora/relation/delegation.rb
active-fedora-7.2.0 lib/active_fedora/relation/delegation.rb
active-fedora-9.1.2 lib/active_fedora/relation/delegation.rb
active-fedora-8.1.0 lib/active_fedora/relation/delegation.rb
active-fedora-9.1.1 lib/active_fedora/relation/delegation.rb
active-fedora-9.1.0 lib/active_fedora/relation/delegation.rb
active-fedora-9.1.0.rc1 lib/active_fedora/relation/delegation.rb
active-fedora-8.0.1 lib/active_fedora/relation/delegation.rb