passive_record 0.3.22 → 0.4.0

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: 0da60516f4dae347da57b1962d23e18b7f827afd
4
- data.tar.gz: 1e0d9f45e271a7d7ea33f67c78a6025b775f0590
3
+ metadata.gz: 1069acdce6a222fdb5eb4be3085be1e70de1be66
4
+ data.tar.gz: 7d7c763b9b7763c48e01417a7b1e4deb6ba74e85
5
5
  SHA512:
6
- metadata.gz: 9059fbac831a498e084e96369e4bff6f80eb1b4e49a62ec65781e352ee96d8dc65cfe5dba2055fa16f3de2257f9a853777f7325cd83c66746701c70dc310a192
7
- data.tar.gz: 25776b650cee40da1991e5ece6c889c72914ecea5f86d9b389e83d094781f091e21168d05774a85552c9bc88096ff356cde6a949b370581f0f2880121fc866b3
6
+ metadata.gz: 099e43e82b801dbf24837c636b15e4ff799c242d354f4840eedda1bb4dcd22d32983c1b729cc179bd56df4e09f2ee86c221424914d11906aae34b84b5e17e9a9
7
+ data.tar.gz: 826ebd2c1c5bd51deb6cf32cbccbabe613cf01bf93fed28dc15f4bf6978e6739f68e85d8689c9d41cbd3eef87c69f9bda9922702e6f2914ceafe34a10bea7978
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
- ruby '2.3.0'
2
+ ruby '2.2.1'
3
3
 
4
4
  gemspec
5
5
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # passive_record
1
+ ![passive record logo](https://raw.githubusercontent.com/deepcerulean/passive_record/master/logo.png)
2
2
 
3
3
 
4
4
  * [Documentation](https://rubygems.org/gems/passive_record)
@@ -12,7 +12,7 @@ module PassiveRecord
12
12
  end
13
13
 
14
14
  def associations_id_syms
15
- @associations&.map do |assn|
15
+ @associations && @associations.map do |assn|
16
16
  if assn.is_a?(HasOneAssociation) || assn.is_a?(BelongsToAssociation)
17
17
  (assn.target_name_symbol.to_s + "_id").to_sym
18
18
  else
@@ -27,7 +27,8 @@ module PassiveRecord
27
27
  associate!(association)
28
28
 
29
29
  define_method(:"#{parent_name_sym}_id") do
30
- send(parent_name_sym)&.id
30
+ prnt = send(parent_name_sym)
31
+ prnt && prnt.id
31
32
  end
32
33
 
33
34
  define_method(parent_name_sym) do
@@ -51,7 +52,8 @@ module PassiveRecord
51
52
  associate!(association)
52
53
 
53
54
  define_method(:"#{child_name_sym}_id") do
54
- send(child_name_sym)&.id
55
+ chld = send(child_name_sym)
56
+ chld && chld.id
55
57
  end
56
58
 
57
59
  define_method(child_name_sym) do
@@ -71,7 +73,8 @@ module PassiveRecord
71
73
  define_method(:"#{child_name_sym}_id=") do |new_child_id|
72
74
  relation = relata.detect { |rel| rel.association == association }
73
75
  # detach existing child...
74
- relation.lookup&.send(:"#{relation.parent_model_id_field}=", nil)
76
+ rel = relation.lookup
77
+ rel && rel.send(:"#{relation.parent_model_id_field}=", nil)
75
78
 
76
79
  relation.child_class.
77
80
  find(new_child_id).
@@ -9,8 +9,8 @@ module PassiveRecord
9
9
  end
10
10
 
11
11
  def ==(other_id)
12
- self.value == other_id ||
13
- (other_id.is_a?(SecureRandomIdentifier) && self.value == other_id&.value)
12
+ self.value == other_id ||
13
+ (other_id.is_a?(SecureRandomIdentifier) && (other_id && self.value == other_id.value))
14
14
  end
15
15
 
16
16
  def inspect
@@ -83,7 +83,9 @@ module PassiveRecord
83
83
  def evaluate_condition(instance, field, value)
84
84
  if value.is_a?(Hash)
85
85
  evaluate_nested_conditions(instance, field, value)
86
- elsif value.is_a?(Range) || value.is_a?(Array)
86
+ elsif value.is_a?(Range)
87
+ value.cover?(instance.send(field))
88
+ elsif value.is_a?(Array)
87
89
  value.include?(instance.send(field))
88
90
  else
89
91
  instance.send(field) == value
@@ -55,7 +55,7 @@ module PassiveRecord
55
55
  private
56
56
 
57
57
  def relata
58
- @_relata ||= self.class.associations&.map do |assn|
58
+ @_relata ||= self.class.associations && self.class.associations.map do |assn|
59
59
  assn.to_relation(self)
60
60
  end || []
61
61
  end
@@ -1,4 +1,4 @@
1
1
  module PassiveRecord
2
2
  # passive_record version
3
- VERSION = "0.3.22"
3
+ VERSION = "0.4.0"
4
4
  end
data/logo.png ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passive_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.22
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Weissman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-16 00:00:00.000000000 Z
11
+ date: 2016-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -162,6 +162,7 @@ files:
162
162
  - lib/passive_record/instance_methods.rb
163
163
  - lib/passive_record/pretty_printing.rb
164
164
  - lib/passive_record/version.rb
165
+ - logo.png
165
166
  - passive_record.gemspec
166
167
  - spec/passive_record_spec.rb
167
168
  - spec/spec_helper.rb
@@ -185,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
186
  version: '0'
186
187
  requirements: []
187
188
  rubyforge_project:
188
- rubygems_version: 2.5.1
189
+ rubygems_version: 2.4.6
189
190
  signing_key:
190
191
  specification_version: 4
191
192
  summary: no-persistence relational algebra