Sha256: 132bb08bafe692d2956926f63e65d6c54d2ca09e5aaca93c22ab95681d550850

Contents?: true

Size: 1.69 KB

Versions: 9

Compression:

Stored size: 1.69 KB

Contents

require 'set'

require 'cassandra_object/log_subscriber'
require 'cassandra_object/types'

module CassandraObject
  class Base
    class << self
      def column_family=(column_family)
        @column_family = column_family
      end

      def column_family
        @column_family ||= base_class.name.pluralize
      end

      def base_class
        class_of_active_record_descendant(self)
      end

      def config=(config)
        @@config = config.is_a?(Hash) ? CassandraObject::Config.new(config) : config
      end

      def config
        @@config
      end

      private

        # Returns the class descending directly from ActiveRecord::Base or an
        # abstract class, if any, in the inheritance hierarchy.
        def class_of_active_record_descendant(klass)
          if klass == Base || klass.superclass == Base
            klass
          elsif klass.superclass.nil?
            raise "#{name} doesn't belong in a hierarchy descending from CassandraObject"
          else
            class_of_active_record_descendant(klass.superclass)
          end
        end
    end

    extend ActiveModel::Naming
    include ActiveModel::Conversion
    extend ActiveSupport::DescendantsTracker

    include Connection
    include Consistency
    include Identity
    include Inspect
    include Persistence
    include AttributeMethods
    include Validations
    include AttributeMethods::Dirty
    include AttributeMethods::PrimaryKey
    include AttributeMethods::Typecasting
    include BelongsTo
    include Callbacks
    include Timestamps
    include Savepoints
    include Scoping
    include Core

    include Serialization
  end
end

ActiveSupport.run_load_hooks(:cassandra_object, CassandraObject::Base)

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
gotime-cassandra_object-4.10.4 lib/cassandra_object/base.rb
gotime-cassandra_object-4.10.3 lib/cassandra_object/base.rb
gotime-cassandra_object-4.10.2 lib/cassandra_object/base.rb
gotime-cassandra_object-4.10.1 lib/cassandra_object/base.rb
cassandra_object_rails-0.0.1 lib/cassandra_object/base.rb
gotime-cassandra_object-4.10.0 lib/cassandra_object/base.rb
gotime-cassandra_object-4.9.2 lib/cassandra_object/base.rb
gotime-cassandra_object-4.9.1 lib/cassandra_object/base.rb
gotime-cassandra_object-4.9.0 lib/cassandra_object/base.rb