sdl 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33252bd783b69ae9ac6fb9e579817a9392dcd3a7
4
- data.tar.gz: aaf572106a7f32f494ea0e4d050e7e5894e70de8
3
+ metadata.gz: '0097ab232199555efc3955e120f59065251710a2'
4
+ data.tar.gz: fc7c8f6704e0b2cd6a7b1930e50078ca1f74b1aa
5
5
  SHA512:
6
- metadata.gz: f4066429d325386c0c79b1b53443ae61f30530a81c87da81b1663ebf2fb4aacfd10132700c13791a0eba3573f1141916e36f588ae7073c41c7d127f5cb5804a7
7
- data.tar.gz: 55bb962046a882e09bee9cb98eeb2ee3afb7c633a6148986f23d7671f638be91aa111b2b077b561b4486dd174b86137a8eb5d002911240e067fc8dc73284487f
6
+ metadata.gz: c4096110627803a917bd2fe3d39127bea5c2e203f3bd48f53597bb100e1f6b502e250873a4ea6743e7f56303f381d5c13a29c79f8a2453af58139bc4c5fdb306
7
+ data.tar.gz: 2fee1715e1f601cb3af618f2158d5d9451af36e3506da0e91665e03264d32af3a9e9b71f2bf24d755a9dd73e094a4cbae33feb5c3327756c121224c757af05e9
@@ -36,6 +36,19 @@ module SDL
36
36
  has_one? || has_many? || belongs_to?
37
37
  end
38
38
 
39
+ # Can this field be null? By default, this is `false`. But, it can
40
+ # be overridden by passing `nullable: true` to a field.
41
+ # @return [Boolean]
42
+ def nullable?
43
+ options.fetch(:nullable, false)
44
+ end
45
+
46
+ # The opposite of {#nullable?}. All fields are required by default
47
+ # @return [Boolean]
48
+ def required?
49
+ !nullable?
50
+ end
51
+
39
52
  # @!method id?
40
53
  # Indicates that this is an {Attribute} whose type is `:id`
41
54
  # @return [Boolean]
@@ -91,12 +104,6 @@ module SDL
91
104
  end
92
105
 
93
106
  module ColumnOptions
94
- # Is this field required?
95
- # @return [Boolean]
96
- def required?
97
- options.fetch(:required, false)
98
- end
99
-
100
107
  # A default value for this field
101
108
  # @return [Object]
102
109
  def default
@@ -28,7 +28,7 @@ module SDL
28
28
  # Adds an {Attribute} to the model
29
29
  # @param name [Symbol]
30
30
  # @param type [Symbol]
31
- # @option options [Boolean] :required
31
+ # @option options [Boolean] :nullable
32
32
  # @option options [Boolean] :unique
33
33
  # @option options [Object] :default
34
34
  # @option options [Integer] :limit
@@ -46,7 +46,7 @@ module SDL
46
46
  # Adds an {Enum} to the model
47
47
  # @param name [Symbol]
48
48
  # @option options [Array<Symbol>] :values
49
- # @option options [Boolean] :required
49
+ # @option options [Boolean] :nullable
50
50
  # @option options [Boolean] :unique
51
51
  # @option options [Object] :default
52
52
  #
@@ -61,7 +61,7 @@ module SDL
61
61
  # Adds an {Association::BelongsTo} to the model
62
62
  # @param name [Symbol]
63
63
  # @option options [Symbol] :model_name
64
- # @option options [Boolean] :required
64
+ # @option options [Boolean] :nullable
65
65
  # @option options [Boolean] :unique
66
66
  # @option options [Boolean] :foreign_key
67
67
  #
@@ -76,6 +76,7 @@ module SDL
76
76
  # Adds an {Association::HasOne} to the model
77
77
  # @param name [Symbol]
78
78
  # @option options [Symbol] :model_name
79
+ # @option options [Boolean] :nullable
79
80
  #
80
81
  # @example
81
82
  # model :user do
@@ -99,7 +100,7 @@ module SDL
99
100
 
100
101
  # Adds an {Attachment::HasOne} to the model
101
102
  # @param name [Symbol]
102
- # @option options [Hash]
103
+ # @option options [Symbol] :nullable
103
104
  #
104
105
  # @example
105
106
  # model :user do
@@ -46,7 +46,7 @@ module SDL
46
46
  # * `has_one_attached`
47
47
  # * `has_many_attached`
48
48
  # * `unique`
49
- # * `required`
49
+ # * `nullable`
50
50
  # * `index`
51
51
  # * `foreign_key`
52
52
  # * `default{value}`
@@ -86,7 +86,7 @@ module SDL
86
86
  ASSOCIATION_WITH_NAME = /^(belongs_to|has_one|has_many)\{(.*)\}$/
87
87
 
88
88
  DEFAULT = /^default\{(.*)\}$/
89
- MODIFIERS = %w[required unique index foreign_key]
89
+ MODIFIERS = %w[nullable unique index foreign_key]
90
90
 
91
91
  def parse!(arg, opts)
92
92
  case arg
@@ -1,3 +1,3 @@
1
1
  module SDL
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ray Zane