schemer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Schemer
2
- VERSION="0.1.0"
2
+ VERSION="0.1.1"
3
3
  end
@@ -2,6 +2,22 @@ require "active_record"
2
2
 
3
3
  module Schemer
4
4
  module ActiveRecord
5
+ # Define a schema on your ActiveRecord model.
6
+ #
7
+ # schema :name, { :age => :integer }, { :birthdate => :datetime }, :summary
8
+ #
9
+ # Table + columns will be added automatically based on your definition.
10
+ #
11
+ # If you remove a column, it will be removed from the table the next time
12
+ # the class is loaded.
13
+ #
14
+ # If you change the type of a column, it will be also be updated the next
15
+ # time the class is loaded.
16
+ #
17
+ # Likewise, adding a new column will add the column to your schema on the
18
+ # next class load.
19
+ #
20
+ # Columns with no types are assumed to be strings.
5
21
  def schema(*args)
6
22
  extend ClassMethods
7
23
 
@@ -2,8 +2,23 @@ require "sequel"
2
2
 
3
3
  module Schemer
4
4
  module Sequel
5
- module ClassMethods
6
- # TODO: document
5
+ module ClassMethods
6
+ # Define a schema on your Sequel model.
7
+ #
8
+ # schema :name, { :age => :integer }, { :birthdate => :datetime }, :summary
9
+ #
10
+ # Table + columns will be added automatically based on your definition.
11
+ #
12
+ # If you remove a column, it will be removed from the table the next time
13
+ # the class is loaded.
14
+ #
15
+ # If you change the type of a column, it will be also be updated the next
16
+ # time the class is loaded.
17
+ #
18
+ # Likewise, adding a new column will add the column to your schema on the
19
+ # next class load.
20
+ #
21
+ # Columns with no types are assumed to be strings.
7
22
  def schema(*args)
8
23
  @schema_columns = {}
9
24
 
@@ -20,14 +35,7 @@ module Schemer
20
35
 
21
36
  def schema_columns
22
37
  @schema_columns
23
- end
24
-
25
- # Update ActiveRecord's automatically generated methods so we don't have to
26
- # reload for schema changes to take effect
27
- def update_methods
28
- # undefine_attribute_methods
29
- # @columns = @column_names = @columns_hash = @generated_methods = nil
30
- end
38
+ end
31
39
 
32
40
  # Update the underlying schema as defined by schema call
33
41
  def update_schema
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schemer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ben Alavi