options_model 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b48f69018888ef5765996819027a9bd0d68981b6
4
- data.tar.gz: 0170a1dc7069a68cc48185a8544522543fbea127
3
+ metadata.gz: d9a37f973ba728533048c53e9a2d775fc0456417
4
+ data.tar.gz: c8a02ff82bd787b11c48fa8a10e7b624b1fc0974
5
5
  SHA512:
6
- metadata.gz: fb560074151d10c1bd1ec3d6d9025e263507c0609c041548d5e6c9be1797c414d678f981cc3678f0ed92866b8c4adf92ce80bc330909b5cd65c5ff4553ac23da
7
- data.tar.gz: 8f72cdfa3d24c02116665f4910c8f3110e66570787938dd76be5c84f3dde6672cca6944b42098c642647285dfe6421196181a9e856b81d6a5091ca006d77f8b4
6
+ metadata.gz: f90a39308bd641d7960c743ed8d7708a15507a6acbce56f8bbc02356af78a461cd7fcc26aa29d7bc1430898eee146721a15a5e6d071ce7444744f6aa46390647
7
+ data.tar.gz: 275841f4c5a6dbd721d567fb2007f2959f233a6aa67a67e5ffeffb8aa876d27a9196a65428973ec7b44309a067c9afc8c49cc281517567d4d2a8f04a23d6b2bb
@@ -12,6 +12,10 @@ module ActiveModel
12
12
  :datetime
13
13
  end
14
14
 
15
+ def serialize(value)
16
+ super(cast(value))
17
+ end
18
+
15
19
  private
16
20
 
17
21
  def cast_value(value)
@@ -21,6 +21,10 @@ module ActiveModel
21
21
  end
22
22
  end
23
23
 
24
+ define_method(:value_constructed_by_mass_assignment?) do |value|
25
+ value.is_a?(Hash)
26
+ end
27
+
24
28
  define_method(:value_from_multiparameter_assignment) do |values_hash|
25
29
  defaults.each do |k, v|
26
30
  values_hash[k] ||= v
@@ -6,7 +6,7 @@ module ActiveModel
6
6
  include Helpers::Numeric
7
7
 
8
8
  # Column storage size in bytes.
9
- # 4 bytes means a MySQL int or Postgres integer as opposed to smallint etc.
9
+ # 4 bytes means an integer as opposed to smallint etc.
10
10
  DEFAULT_LIMIT = 4
11
11
 
12
12
  def initialize(*)
@@ -86,6 +86,10 @@ module ActiveModel
86
86
  false
87
87
  end
88
88
 
89
+ def value_constructed_by_mass_assignment?(_value) # :nodoc:
90
+ false
91
+ end
92
+
89
93
  def map(value) # :nodoc:
90
94
  yield value
91
95
  end
@@ -32,6 +32,10 @@ module ActiveModel
32
32
  def lookup(*args, **kwargs) # :nodoc:
33
33
  registry.lookup(*args, **kwargs)
34
34
  end
35
+
36
+ def default_value # :nodoc:
37
+ @default_value ||= Value.new
38
+ end
35
39
  end
36
40
 
37
41
  register(:big_integer, Type::BigInteger)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OptionsModel
4
- VERSION = "0.0.7"
4
+ VERSION = "0.0.8"
5
5
  end
data/lib/options_model.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_model"
4
- require "active_model/type"
5
4
 
6
5
  require "options_model/concerns/attribute_assignment"
7
6
  require "options_model/concerns/attributes"
@@ -10,7 +9,7 @@ require "options_model/concerns/serialization"
10
9
 
11
10
  require "options_model/base"
12
11
 
13
- unless defined?(ActiveModel::Type)
12
+ if ActiveModel.gem_version < Gem::Version.new("5.0.0")
14
13
  require "active_model/type"
15
14
  end
16
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: options_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-05 00:00:00.000000000 Z
11
+ date: 2017-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel