Sha256: c09b0afb22f5b6830f9f6c8f35c325c238a7c30918067e0e988ae1188e2e9863

Contents?: true

Size: 873 Bytes

Versions: 2

Compression:

Stored size: 873 Bytes

Contents

module Mobility
=begin

Class to access Mobility across backends. In particular, keeps a record of
which {Attributes} modules have been included on the model class. It is also a
simple delegator, so any missing method will be delegated to the model class.

=end
  class Accumulator
    # @return [Array<Attributes>]
    attr_reader :modules

    # @param [Class] model_class Model class
    def initialize
      @modules = []
    end

    # @return [Array<String>] Translated attributes defined on model
    def translated_attribute_names
      modules.map(&:names).flatten
    end

    # Appends backend module to +modules+ array for later reference.
    # @param [Attributes] backend_module Attributes module
    def << backend_module
      modules << backend_module
    end

    def initialize_dup(other)
      @modules = other.modules.dup
      super
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mobility-0.5.1 lib/mobility/accumulator.rb
mobility-0.5.0 lib/mobility/accumulator.rb