sequel_bitemporal 0.8.7 → 0.8.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: e6ceef30532508ab4b24ce154fb5d1f8c583b4cb
4
- data.tar.gz: b4b0f467b224ae49e5a364eb847ae600dd17efbc
3
+ metadata.gz: fc21e82b40ea8f3f5dc15e28ed49dfd2d5cb9b1d
4
+ data.tar.gz: b96f3457b381585ba37c2b81825c3d387225fabd
5
5
  SHA512:
6
- metadata.gz: 042a681c1ed64b5a5ab4afc08fdcd9d432e8952b5812c46e89c810f02ddc5e974020925b23a8e627d7b8c6b0617cf53df63f2de72ae32398d05de792b7f30d55
7
- data.tar.gz: f74d5a8e11dba813cad25ad33d9d8ef7469b7953d4cc80cf55e1a68b5994c498cbc81777c284da9c456fa1f8775ec4449cbf60d7eb7f5412b01424b826a13712
6
+ metadata.gz: 2c0883049c494836a9579c2442c194e79100587fa2f187ef5a99a8f96e938979e09bf64f2c807e1543a4d4ba2c4f430ce4c14e8700263df9e54f1097a3319c28
7
+ data.tar.gz: 98d110e00b4f2d4f075f338820bcfbf717790c4447cc87f6049f9b99276fbe159ce8f27cb373a252c1a16a586e8e5ea8a36333d2900d63de00d29a029a7528d8
data/README.md CHANGED
@@ -41,9 +41,12 @@ Usage
41
41
  Thanks
42
42
  ------
43
43
 
44
- Thanks to Evgeniy L (fiscal-cliff on github) for his contributions:
44
+ Thanks to Evgeniy L (@fiscal-cliff) for his contributions:
45
45
  - skip plugin initialization process if versions table does not exist
46
46
 
47
+ Thanks to Ksenia Zalesnaya (@ksenia-zalesnaya) for her contributions:
48
+ - define setter methods for versioned columns
49
+
47
50
  License
48
51
  -------
49
52
 
@@ -182,13 +182,22 @@ module Sequel
182
182
  end
183
183
  unless opts[:delegate]==false
184
184
  (version.columns-master.columns-master.excluded_columns).each do |column|
185
- master.class_eval <<-EOS
185
+ master.class_eval <<-EOS, __FILE__, __LINE__ + 1
186
186
  def #{column}
187
187
  pending_or_current_version.#{column} if pending_or_current_version
188
188
  end
189
189
  EOS
190
190
  end
191
191
  end
192
+ if opts[:writers]
193
+ (version.columns-master.columns-master.excluded_columns).each do |column|
194
+ master.class_eval <<-EOS, __FILE__, __LINE__ + 1
195
+ def #{column}=(value)
196
+ self.attributes = {"#{column}" => value}
197
+ end
198
+ EOS
199
+ end
200
+ end
192
201
  end
193
202
  module ClassMethods
194
203
  attr_reader :version_class, :versions_alias, :current_version_alias,
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "sequel_bitemporal"
6
- s.version = "0.8.7"
6
+ s.version = "0.8.8"
7
7
  s.authors = ["Joseph HALTER", "Jonathan TRON"]
8
8
  s.email = ["joseph.halter@thetalentbox.com", "jonathan.tron@thetalentbox.com"]
9
9
  s.homepage = "https://github.com/TalentBox/sequel_bitemporal"
@@ -585,6 +585,25 @@ describe "Sequel::Plugins::Bitemporal" do
585
585
  expect(master.price).to eq(98)
586
586
  DB.drop_table :rooms_with_name
587
587
  end
588
+ it "allow assigning version attributes in master only with option writers" do
589
+ closure = @version_class
590
+ with_writers_class = Class.new Sequel::Model do
591
+ set_dataset :rooms
592
+ plugin :bitemporal, version_class: closure, writers: true
593
+ end
594
+ master = @master_class.new
595
+ expect{ master.name = "Single Standard" }.to raise_error NoMethodError
596
+ master = with_writers_class.new
597
+ expect(master.attributes).to eq({})
598
+ expect(master.pending_version).to be_nil
599
+ expect(master.current_version).to be_nil
600
+ expect(master.name).to be_nil
601
+ master.name = "Single Standard"
602
+ expect(master.attributes).to include({name: "Single Standard"})
603
+ expect(master.pending_version).to be
604
+ expect(master.pending_or_current_version.name).to eq("Single Standard")
605
+ expect(master.name).to eq("Single Standard")
606
+ end
588
607
  it "get current_version association name from class name" do
589
608
  class MyNameVersion < Sequel::Model
590
609
  set_dataset :room_versions
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_bitemporal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.7
4
+ version: 0.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph HALTER
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-04 00:00:00.000000000 Z
12
+ date: 2016-08-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sequel