Sha256: 0a4d442ace4d604fcdf59f2ad4efad0f9d9936254256c7f81ff5147db0998240

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

require 'active_model/conversion'
require 'active_model/naming'
require 'plain_model/modeling/base'
require 'plain_model/modeling/queryable'
require_relative 'modeling/scope'
require_relative 'modeling/query'
require_relative 'modeling/attributes'
require_relative 'modeling/connection'
require_relative 'logging'

module ActiveHouse
  class Model
    extend PlainModel::Modeling::Queryable
    include ActiveModel::Model
    include ActiveHouse::Modeling::Scope
    include ActiveHouse::Modeling::Query
    include ActiveHouse::Modeling::Attributes
    include ActiveHouse::Modeling::Connection
    include ActiveHouse::Logging

    Column = Struct.new(:name)
    class_attribute :_table_name, instance_accessor: false

    class << self
      def table_name(name)
        self._table_name = name.to_s
      end

      def columns
        return @columns if defined?(@columns)

        @columns = attribute_types.keys.map { |name| Column.new(name.to_sym) }
      end

      def column_names
        columns.map(&:name)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
active_house-0.6.6 lib/active_house/model.rb
active_house-0.6.5 lib/active_house/model.rb
active_house-0.6.4 lib/active_house/model.rb
active_house-0.6.3 lib/active_house/model.rb
active_house-0.6.2 lib/active_house/model.rb
active_house-0.6.1 lib/active_house/model.rb
active_house-0.6.0 lib/active_house/model.rb
active_house-0.5.1 lib/active_house/model.rb