attributable 0.0.3 → 0.0.4

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 167cb3bfb8d4237095209222dd5e925e909b3e6c
4
- data.tar.gz: 99d532b61ef03948d2e43a3c00412f54323a7978
3
+ metadata.gz: c22dc4806f8e50155cb39df375de2e883edfb086
4
+ data.tar.gz: 5edda9c0de87966920404d14b07a8ca78e395657
5
5
  SHA512:
6
- metadata.gz: 3b6b9812417f37be3717ce38c74dd04c4e13ba0ddda2278aa7684aeca11f3a0fb234a1bcb3b3359c52c98ad8cdbf1e432473b3f2bdb71a0edff1b0cdbcb33400
7
- data.tar.gz: dd81b2cc7552dfe36f6d2f9ca1b69b8197055439f6e728615695493741481816674038169dd33d22053a6773424becb84ebe6cfa36a63a3cd2a8c722a031597c
6
+ metadata.gz: b50d6942f2276f8571991bb33470191cceb7a215bc78d0e5318466249bba357c443a3e244db843b09ae8a582fdade35e03492666f29eecd1eccc43ebb4f02e77
7
+ data.tar.gz: ee3fad3f3cffafc5fe94d0ef27c56c590e06cbbcc8708f73aa51fe1e0a429b2179b471a3cea5259df251428d45003265476c2e13abc800f5019f477e6be724c0
data/lib/attributable.rb CHANGED
@@ -16,7 +16,6 @@ module Attributable
16
16
  @predefined_attributes ||= {}
17
17
  @predefined_attributes = super_attributes.merge(@predefined_attributes)
18
18
  add_instance_methods(@predefined_attributes)
19
- @predefined_attributes
20
19
  end
21
20
 
22
21
  private
@@ -44,7 +43,8 @@ module Attributable
44
43
 
45
44
  define_method "initialize_attributes" do |attributes = {}|
46
45
  if self.class.superclass.kind_of? Attributable
47
- predefined_attributes = self.class.specialises(self.class.superclass)
46
+ super_attributes = self.class.superclass.new.instance_variable_get(:@attributes)
47
+ predefined_attributes = super_attributes.merge(predefined_attributes)
48
48
  end
49
49
  @attributes = predefined_attributes.merge(attributes)
50
50
  end
@@ -1,3 +1,3 @@
1
1
  module Attributable
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -95,17 +95,30 @@ describe Attributable do
95
95
  expect(s.active).to be_false
96
96
  end
97
97
 
98
+ it "should not override any custom methods" do
99
+ class SuperUser7 < User
100
+ def inspect
101
+ "SUPERUSER"
102
+ end
103
+ end
104
+
105
+ s = SuperUser7.new(id: 1)
106
+
107
+ expect(s.id).to eq(1)
108
+ expect(s.inspect).to eq("SUPERUSER")
109
+ end
110
+
98
111
  it "shouldn't automatically specialise unless superclass is an instance of Attributable" do
99
112
  class PORO
100
113
  attr_accessor :name
101
114
  end
102
115
 
103
- class SuperUser7 < PORO
116
+ class SuperUser8 < PORO
104
117
  extend Attributable
105
118
  attributes :forename, :surname
106
119
  end
107
120
 
108
- expect { SuperUser7.new }.to_not raise_error
121
+ expect { SuperUser8.new }.to_not raise_error
109
122
  end
110
123
  end
111
124
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attributable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Rose