Sha256: 9b039bb6e173ad6b068449620871f5aa07aea6c55ef0274655c14b917ec4b16f

Contents?: true

Size: 1.02 KB

Versions: 13

Compression:

Stored size: 1.02 KB

Contents

require_relative 'attributes/type_map'
require_relative 'attributes/lazy'

require_relative 'attributes/builder'

require_relative 'attributes/enum'

module Torque
  module PostgreSQL
    module Attributes
      extend ActiveSupport::Concern

      # Configure enum_save_on_bang behavior
      included do
        class_attribute :enum_save_on_bang, instance_accessor: true
        self.enum_save_on_bang = Torque::PostgreSQL.config.enum.save_on_bang
      end

      module ClassMethods

        private

          # If the attributes are not loaded,
          def method_missing(method_name, *args, &block)
            return super unless define_attribute_methods
            self.send(method_name, *args, &block)
          end

          # Use local type map to identify attribute decorator
          def define_attribute_method(attribute)
            type = attribute_types[attribute]
            super unless TypeMap.lookup(type, self, attribute, true)
          end

      end
    end

    ActiveRecord::Base.include Attributes
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
torque-postgresql-0.2.13 lib/torque/postgresql/attributes.rb
torque-postgresql-0.2.12 lib/torque/postgresql/attributes.rb
torque-postgresql-0.2.11 lib/torque/postgresql/attributes.rb
torque-postgresql-0.2.10 lib/torque/postgresql/attributes.rb
torque-postgresql-0.2.9 lib/torque/postgresql/attributes.rb
torque-postgresql-0.2.8 lib/torque/postgresql/attributes.rb
torque-postgresql-0.2.7 lib/torque/postgresql/attributes.rb
torque-postgresql-0.2.6 lib/torque/postgresql/attributes.rb
torque-postgresql-0.2.5 lib/torque/postgresql/attributes.rb
torque-postgresql-0.2.4 lib/torque/postgresql/attributes.rb
torque-postgresql-0.2.3 lib/torque/postgresql/attributes.rb
torque-postgresql-0.2.2 lib/torque/postgresql/attributes.rb
torque-postgresql-0.2.1 lib/torque/postgresql/attributes.rb