has_attributes 0.0.4 → 0.0.5

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzJlODZkMGM5MTI5NWFiYzM5YTE3NDYxNzgxODg2MjA3MGJlZTIyZg==
4
+ ZTEzYjJiZGFmZGQ5NTQ1YjFkNDA1ZDIzMThhZTk5OWM2YTFlMDc5ZA==
5
5
  data.tar.gz: !binary |-
6
- MjNmNTRkYTMwNTVkMzg4YTBkNzVmOGU3ODA4ODRiNjNhNmIwMjhjMQ==
6
+ ZjI1NWZlYTBhOGZkY2E3YzYxZDk5ZjA0NmU5YjE4MjA5NThlYWY3Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjVlNmUyNTlkMWViMzEzZDE1YzI3NzkwN2Q1YmU5ZDJmYjFiYmE4ZWQyMDUy
10
- ZDJmNzMzNzc1YzVmNTk1MzQwYmMwMDcwZmIzYzgyNDQ2NTUwMzBhMzI0Zjhj
11
- NWZlMzNkZmQ4OTU5ZWViN2YzMTQwNDQyNDZiMDViZDFhMDg4ZGE=
9
+ NGQ3ZTRjMTVmYzIwZTcwMWJiMDU4ZTY0MjhjYmU0NWM2MDAyYzA3NmJjZjIx
10
+ NjY4ZWFkOTAyMTZiNjM2MjRhNDFmNzk1MGJhNmZlMzhiMGQyMjU3OTQ2ZjBh
11
+ YzZmNzM5YTNjMzBkY2Q5ZTVhM2M1YmMxMmNlMjY0YjMyOTk4MDg=
12
12
  data.tar.gz: !binary |-
13
- NmQxZGFjMWY1YzQ1M2VkZTMwYTcwNjdjNGY0MmZkMTNhNGY4ODVhNWI0OTk1
14
- YmFhNmEwNzE3NTQwMjEyMTk2NDI2NWU5OGQzZjc3MGNjM2M2OTVhNTY4OGM3
15
- OWJmOTA4YzA2NGE2NmUwNTQzNDEwNDBjZDIzODAzYTNhNDlmMGQ=
13
+ YTU5YWFmNmM5ZTkwMDNjYmVmYzU0ODE2NDU3YzI2N2I1NDdkNjE4MjA0YWFi
14
+ MGFiODE3YzdiMjQ1ZjA5NGI2MTJjNzk0NmRhMmRlMWZjNjVhOGVmZGI5MDJm
15
+ YmJiMzM3NzM2YzBkMjViZTU2NmY0ZTQ5MDYxZWUzNTIzZmY3Yzc=
data/History.md CHANGED
@@ -1,4 +1,10 @@
1
- 0.0.3 / 2014-02-08
1
+ 0.0.5 / 2014-02-10
2
+ ==================
3
+
4
+ * Guard against nils, revert setting model_attributes to empty set in included hook
5
+
6
+
7
+ 0.0.4 / 2014-02-08
2
8
  ==================
3
9
 
4
10
  * Set model_attributes to an empty set in included hook
@@ -4,7 +4,6 @@ require "set"
4
4
  module HasAttributes
5
5
  def self.included(base)
6
6
  base.class.send(:attr_accessor, :model_attributes)
7
- base.send(:model_attributes=, Set.new)
8
7
  base.extend(ClassMethods)
9
8
  end
10
9
 
@@ -19,7 +18,7 @@ module HasAttributes
19
18
  Set.new
20
19
  end
21
20
 
22
- attrs = model_attributes.merge(attrs.map(&:to_sym))
21
+ attrs = (model_attributes || Set.new).merge(attrs.map(&:to_sym))
23
22
 
24
23
  if inherit_parent_attributes
25
24
  attrs = parent_attributes.merge(attrs)
@@ -39,13 +38,13 @@ module HasAttributes
39
38
  end
40
39
 
41
40
  def attributes=(attrs)
42
- self.class.model_attributes.each do |attr|
41
+ (self.class.model_attributes || Set.new).each do |attr|
43
42
  public_send((attr.to_s << "=").to_sym, attrs[attr])
44
43
  end
45
44
  end
46
45
 
47
46
  def attributes
48
- self.class.model_attributes.reduce({}) do |memo, attr|
47
+ (self.class.model_attributes || Set.new).reduce({}) do |memo, attr|
49
48
  unless (value = public_send(attr)).nil?
50
49
  memo[attr] = value
51
50
  end
@@ -1,3 +1,3 @@
1
1
  module HasAttributes
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Reinhart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-09 00:00:00.000000000 Z
11
+ date: 2014-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler