Class: Theman::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/theman/object.rb

Class Method Summary collapse

Class Method Details

.new(table_name, parent = ::Object, conn = nil) ⇒ Object

create a new basic model object

Parameters

  • table_name - the name of the table created by Theman::Agency

  • parent - optional parent object for the new basic model object usually ActiveRecord::Base

  • conn - optional pg connection

Example

my_model = Theman::Object.new(agent.table_name, ActiveRecord::Base)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/theman/object.rb', line 11

def self.new(table_name, parent = ::Object, conn = nil)
  Class.new(parent) do
    unless conn.nil?
      @@connection = conn
    end
    instance_eval <<-EOV, __FILE__, __LINE__ + 1
      set_table_name "#{table_name}"
      
      def table_name
        "#{table_name}"
      end
      
      def inspect
        "Agent (#{table_name})"
      end
    EOV
  end
end