couchbase-orm 0.0.6 → 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: 6b68fe44cc7da799f2e87e010a86bbdc8110afae
4
- data.tar.gz: 2261e2cbe3d2d7daac611f9aa167ffdad4683495
3
+ metadata.gz: 6180a380880e394f4d1708aa67048db9adcfb18a
4
+ data.tar.gz: 028684cab7ef06b41a5aecbfc56b29826fa85230
5
5
  SHA512:
6
- metadata.gz: 52dd91e8aea71e0d3048486b4de9a7fa48ad6a5fe55e5e141c5037beb0b71764fab67ba22f6706372cf61b7a4a8c2d0dd3054a39d4d1c76c51a4b83f7bacea2d
7
- data.tar.gz: dfaf5da9c871352fb05a75e3c670ca82f735641ffe0945943e609a519694c10881e7b62c2de04a62ff5202a918405f66bc08c20d89d1d4187a6f601067606416
6
+ metadata.gz: 1302271d05d4302ec5c5a27c4d408d2c746fc3074b999e38533e0d9f3bc6fdd423ae30be0f84b4c36012b593a41a504960b2000a95929c5d18591f6a7a60d131
7
+ data.tar.gz: 19f91c2fa122d7a212f2364c0b614af39b11ecba3ba5bcea1b361609fe88c265927a0c619bdd9ef13d24403fb78dfc803f3ea5bc37f52fe074d576ff98de4b16
@@ -20,7 +20,7 @@ module CouchbaseOrm
20
20
  include ::ActiveModel::Dirty
21
21
  include ::ActiveModel::Serializers::JSON
22
22
 
23
- extend ::ActiveModel::Callbacks
23
+ include ::ActiveModel::Validations
24
24
  include ::ActiveModel::Validations::Callbacks
25
25
  define_model_callbacks :initialize, :only => :after
26
26
  define_model_callbacks :create, :destroy, :save, :update
@@ -71,15 +71,19 @@ module CouchbaseOrm
71
71
  name = name.to_sym
72
72
 
73
73
  @attributes[name] = options
74
- next if self.instance_methods.include?(name)
75
74
 
76
- define_method(name) do
77
- read_attribute(name)
75
+ unless self.instance_methods.include?(name)
76
+ define_method(name) do
77
+ read_attribute(name)
78
+ end
78
79
  end
79
80
 
80
- define_method(:"#{name}=") do |value|
81
- value = yield(value) if block_given?
82
- write_attribute(name, value)
81
+ eq_meth = :"#{name}="
82
+ unless self.instance_methods.include?(eq_meth)
83
+ define_method(eq_meth) do |value|
84
+ value = yield(value) if block_given?
85
+ write_attribute(name, value)
86
+ end
83
87
  end
84
88
  end
85
89
  end
@@ -187,7 +187,7 @@ module CouchbaseOrm
187
187
 
188
188
 
189
189
  def _update_record(with_cas: false, **options)
190
- return false unless perform_validations(options)
190
+ return false unless perform_validations(:update, options)
191
191
  return true unless changed?
192
192
 
193
193
  run_callbacks :update do
@@ -211,7 +211,7 @@ module CouchbaseOrm
211
211
  end
212
212
 
213
213
  def _create_record(**options)
214
- return false unless perform_validations(options)
214
+ return false unless perform_validations(:create, options)
215
215
 
216
216
  run_callbacks :create do
217
217
  run_callbacks :save do
@@ -232,8 +232,8 @@ module CouchbaseOrm
232
232
  end
233
233
  end
234
234
 
235
- def perform_validations(options = {})
236
- return valid? if options[:validate] != false
235
+ def perform_validations(context, options = {})
236
+ return valid?(context) if options[:validate] != false
237
237
  true
238
238
  end
239
239
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true, encoding: ASCII-8BIT
2
2
 
3
3
  module CouchbaseOrm
4
- VERSION = '0.0.6'
4
+ VERSION = '0.0.8'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchbase-orm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen von Takach