class RareMap::Model

RareMap::Model defines the details of an ActiveRecord model. @author Wei-Ming Wu @!attribute [r] db_name

@return [String] the name of the database

@!attribute [r] connection

@return [Hash] the connection config of this Model

@!attribute [r] table

@return [Table] the Table of this Model

@!attribute [r] group

@return [String] the group of this Model

@!attribute relations

@return [Array] an Array of Relation of this Model

Attributes

connection[R]
db_name[R]
group[R]
relations[RW]
table[R]

Public Class Methods

new(db_name, connection, table, group = 'default') click to toggle source

Creates a Model.

@param db_name [String] the name of database @param connection [Hash] the connection config of ActiveRecord @param table [Table] the database table @param group [String] the group name of this Model @return [Model] a Model object

# File lib/rare_map/model.rb, line 29
def initialize(db_name, connection, table, group = 'default')
  @db_name, @connection, @table, @group = db_name, connection, table, group
  @relations = []
end

Public Instance Methods

classify() click to toggle source

Returns the class name of this Model.

@return [String] the class name of this Model

# File lib/rare_map/model.rb, line 44
def classify
  "#{table.name}".pluralize.classify
end
group?() click to toggle source

Checks if this Model belongs to a group.

@return [true, false] true if this Model contains a group, false otherwise

# File lib/rare_map/model.rb, line 37
def group?
  group != 'default'
end