Class: Rulengine::Engine

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEngine



34
35
36
37
# File 'lib/rulengine.rb', line 34

def initialize
  puts "init rulengine"
    build_db
end

Class Method Details

.aObject



39
40
41
42
# File 'lib/rulengine.rb', line 39

def self.a
  puts 'a'
  'a'
end

.build_dbObject

TODO



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rulengine.rb', line 13

def self.build_db
  ActiveRecord::Schema.define do
    unless ActiveRecord::Base.connection.tables.include? 'rules'
      create_table :rules do |t|
        t.json :given # Turns this an its negative into a separate 'fact' class
        t.json :unless_given # Same as "and not given"
        t.json :action # switch to foreign key? Model name? (inherited)

        t.timestamps
      end
    end

    unless ActiveRecord::Base.connection.tables.include? 'states'
      create_table :states do |t|
        t.json :data
        t.timestamps
      end
    end
  end
end