Module: Schemata::Schema

Included in:
Orm::ActiveRecord::Schema
Defined in:
lib/schemata.rb,
lib/schemata/schema.rb,
lib/schemata/schema/nameable.rb,
lib/schemata/schema/addressable.rb,
lib/schemata/schema/contactable.rb

Overview

Influenced by devise’s schema module. Methods defined here will be available within migartion files to apply a schema concept.

Instance Method Summary collapse

Instance Method Details

#addressableObject

Provides a common set of address fields such as, street_address_1, street_address_2, city, state, zip_code and country as String fields.



6
7
8
9
10
11
12
13
# File 'lib/schemata/schema/addressable.rb', line 6

def addressable
  apply_schema :street_address_1, String
  apply_schema :street_address_2, String
  apply_schema :city, String
  apply_schema :state, String
  apply_schema :zip_code, String
  apply_schema :country, String
end

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

Note:

Overwrite with specific modification to create your own schema.

Raises:

  • (NotImplementedError)


4
5
6
# File 'lib/schemata/schema.rb', line 4

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

#contactableObject



3
4
5
6
7
# File 'lib/schemata/schema/contactable.rb', line 3

def contactable
  nameable
  apply_schema :email_address, String
  apply_schema :phone_number, String
end

#nameableObject



3
4
5
6
7
# File 'lib/schemata/schema/nameable.rb', line 3

def nameable
  apply_schema :first_name, String
  apply_schema :middle_name, String
  apply_schema :last_name, String
end