Module: Opinio::Schema

Included in:
Orm::ActiveRecord::Schema
Defined in:
lib/opinio/schema.rb

Instance Method Summary collapse

Instance Method Details

#apply_opinio_schema(name, type, options = {}) ⇒ Object

Overwrite with specific modification to create your own schema.

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/opinio/schema.rb', line 16

def apply_opinio_schema(name, type, options={})
  raise NotImplementedError
end

#opinio(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/opinio/schema.rb', line 4

def opinio(options = {})
  null    = options[:null] || false
  default = options.key?(:default) ? options[:default] : ("" if null == false)

  apply_opinio_schema :owner_id, :integer, :null => false
  apply_opinio_schema :commentable_id, :integer, :null => false
  apply_opinio_schema :commentable_type, :string, :null => false
  apply_opinio_schema :title, :string, :default => default, :null => null if options[:title]
  apply_opinio_schema :body, :text, :null => false
end