Class: Marsdawn::Storage::ActiveRecord::Marsdawn

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/marsdawn/storage/active_record/marsdawn.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/marsdawn/storage/active_record/marsdawn.rb', line 5

def data
  @data
end

#docObject

Returns the value of attribute doc.



5
6
7
# File 'lib/marsdawn/storage/active_record/marsdawn.rb', line 5

def doc
  @doc
end

#langObject

Returns the value of attribute lang.



5
6
7
# File 'lib/marsdawn/storage/active_record/marsdawn.rb', line 5

def lang
  @lang
end

#uriObject

Returns the value of attribute uri.



5
6
7
# File 'lib/marsdawn/storage/active_record/marsdawn.rb', line 5

def uri
  @uri
end

#versionObject

Returns the value of attribute version.



5
6
7
# File 'lib/marsdawn/storage/active_record/marsdawn.rb', line 5

def version
  @version
end

Class Method Details

.create_unless_existsObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/marsdawn/storage/active_record/marsdawn.rb', line 7

def self.create_unless_exists
  unless ActiveRecord::Base.connection.table_exists? self.table_name
    ActiveRecord::Migration.create_table :marsdawn do |t|
      t.string :doc, :null => false
      t.string :lang, :null => false
      t.string :version, :null => false
      t.string :uri, :null => false
      t.text   :data
    end
    ActiveRecord::Migration.add_index :marsdawn, [:doc, :lang, :version, :uri], :unique => true
  end
end