module Schemata::Schema

require ‘schemata/engine’ if defined?(Rails) && Rails::VERSION::MAJOR == 3 require ‘schemata/railtie’

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

Public Instance Methods

addressable() click to toggle source

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

# 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={}) click to toggle source

@note Overwrite with specific modification to create your own schema.

# File lib/schemata/schema.rb, line 4
def apply_schema(name, type, options={})
  raise NotImplementedError
end
contactable() click to toggle source
# File lib/schemata/schema/contactable.rb, line 3
def contactable
  nameable
  apply_schema :email_address, String
  apply_schema :phone_number, String
end
nameable() click to toggle source
# 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