Sha256: f47633ed23f705f1a86c7459b80ad2c51ec006e6b10f1037d732cd1befe94be1

Contents?: true

Size: 866 Bytes

Versions: 15

Compression:

Stored size: 866 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 Wrapper < SimpleDelegator
    # @return [Array<Attributes>]
    attr_reader :modules
    alias :model_class :__getobj__

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

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

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mobility-0.1.16 lib/mobility/wrapper.rb
mobility-0.1.15 lib/mobility/wrapper.rb
mobility-0.1.14 lib/mobility/wrapper.rb
mobility-0.1.13 lib/mobility/wrapper.rb
mobility-0.1.12 lib/mobility/wrapper.rb
mobility-0.1.11 lib/mobility/wrapper.rb
mobility-0.1.10 lib/mobility/wrapper.rb
mobility-0.1.7 lib/mobility/wrapper.rb
mobility-0.1.6 lib/mobility/wrapper.rb
mobility-0.1.5 lib/mobility/wrapper.rb
mobility-0.1.4 lib/mobility/wrapper.rb
mobility-0.1.3 lib/mobility/wrapper.rb
mobility-0.1.2 lib/mobility/wrapper.rb
mobility-0.1.1 lib/mobility/wrapper.rb
mobility-0.1.0 lib/mobility/wrapper.rb