hashme 0.2.3 → 0.2.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: eeb34cad001a9e72ba6e9bd7a7f1ea26df382bc0
4
- data.tar.gz: 84add3cad188a7a7ef18966416a1a5e5bbd96230
3
+ metadata.gz: 6f661ccdfd584ab3c1da7e2b5681a16d65063680
4
+ data.tar.gz: c50294da6a1433fdf17b24896a4fc1c6eafe3cff
5
5
  SHA512:
6
- metadata.gz: 3169335c642413fc0ab103c962419e2c3c2ae6bd5202a5aae0cd8995b86fe23df891bc39ec0be59f7475321b0160697c0297a353c249c1769905f335c9ec31d4
7
- data.tar.gz: 57d07bc8e59fad1f67315c2276d654a371c76076699140f65c8edd971f7458e298032f228704b291063a042b91bb425570c7d59b2bc5e452a5d3340d2077500f
6
+ metadata.gz: ac96d51a4764a70037e5b693fc27ebbb08463363ce0d626b7382efbdf0b9ab16e1af12cb94be200595a26fbac7fb272125741e0921876b20dca9954f27dd0b38
7
+ data.tar.gz: 6104d65c1741d731405f492bafb59aeb4b57189b4d18096928b75272f91558dbb126304e01c27ba6dc5ffcd6e95f3fc5ab58680bc7be6986e0729e840c71741f
data/README.md CHANGED
@@ -118,6 +118,10 @@ u.errors.first # [:email, "can't be blank"]
118
118
 
119
119
  ## History
120
120
 
121
+ ### 0.2.4 - 2016-06-03
122
+
123
+ * Removing `casted_by` property, due to lack of use case and complication it causes.
124
+
121
125
  ### 0.2.3 - 2016-06-03
122
126
 
123
127
  * Fixing bug with validation on CastedArrays
data/lib/hashme.rb CHANGED
@@ -12,7 +12,6 @@ require "active_support/json"
12
12
  # Local dependencies
13
13
 
14
14
  require "hashme/attributes"
15
- require "hashme/castable"
16
15
  require "hashme/casted_array"
17
16
  require "hashme/properties"
18
17
  require "hashme/property"
@@ -26,7 +25,6 @@ module Hashme
26
25
  include Validations
27
26
 
28
27
  included do
29
- include Castable
30
28
  include Attributes
31
29
  include Properties
32
30
  end
@@ -10,7 +10,8 @@ module Hashme
10
10
  #
11
11
  class CastedArray
12
12
  extend Forwardable
13
- include Castable
13
+
14
+ attr_reader :property
14
15
 
15
16
  def_delegators :@_array,
16
17
  :to_a, :==, :eql?, :size,
@@ -22,8 +23,7 @@ module Hashme
22
23
 
23
24
  def initialize(property, owner, values = [])
24
25
  @_array = []
25
- self.casted_by = owner
26
- self.casted_by_property = property
26
+ @property = property
27
27
  if values.respond_to?(:each)
28
28
  values.each do |value|
29
29
  self.push(value)
@@ -54,7 +54,7 @@ module Hashme
54
54
  protected
55
55
 
56
56
  def instantiate_and_build(obj)
57
- casted_by_property.build(self, obj)
57
+ property.build(self, obj)
58
58
  end
59
59
 
60
60
  end
@@ -18,11 +18,7 @@ module Hashme
18
18
  elsif CASTABLE_TYPES.include?(type)
19
19
  send('typecast_to_'+type.to_s.downcase, value)
20
20
  else
21
- # Complex objects we don't know how to cast
22
- type.new(value).tap do |obj|
23
- obj.casted_by = owner if obj.respond_to?(:casted_by=)
24
- obj.casted_by_property = property if obj.respond_to?(:casted_by_property=)
25
- end
21
+ type.new(value)
26
22
  end
27
23
  end
28
24
 
@@ -1,3 +1,3 @@
1
1
  module Hashme
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -25,9 +25,8 @@ describe Hashme::CastedArray do
25
25
  expect(@obj.length).to eql(1)
26
26
  end
27
27
 
28
- it "should set owner and property" do
29
- expect(@obj.casted_by).to eql(owner)
30
- expect(@obj.casted_by_property).to eql(property)
28
+ it "should set property" do
29
+ expect(@obj.property).to eql(property)
31
30
  end
32
31
 
33
32
  it "should instantiate and cast each value" do
@@ -49,9 +48,6 @@ describe Hashme::CastedArray do
49
48
  expect(subject.last.class).to eql(submodel)
50
49
  expect(subject.first.name).to eql('test')
51
50
  expect(subject.last.name).to eql('test2')
52
-
53
- expect(subject.last.casted_by).to be(subject)
54
- expect(subject.last.casted_by_property).to eql(property)
55
51
  end
56
52
 
57
53
  end
@@ -60,13 +60,6 @@ describe Hashme::Property do
60
60
  expect(obj.class).to eql(Time)
61
61
  expect(obj).to eql(Time.utc(2013, 6, 2, 12, 0, 0))
62
62
  end
63
-
64
- it "should assign casted by and property" do
65
- prop = subject.new(:item, submodel)
66
- obj = prop.build(owner, {:name => 'test'})
67
- expect(obj.casted_by).to eql(owner)
68
- expect(obj.casted_by_property).to eql(prop)
69
- end
70
63
  end
71
64
 
72
65
  context "with an array" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Lown
@@ -82,7 +82,6 @@ files:
82
82
  - hashme.gemspec
83
83
  - lib/hashme.rb
84
84
  - lib/hashme/attributes.rb
85
- - lib/hashme/castable.rb
86
85
  - lib/hashme/casted_array.rb
87
86
  - lib/hashme/properties.rb
88
87
  - lib/hashme/property.rb
@@ -1,10 +0,0 @@
1
- module Hashme
2
- module Castable
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- attr_accessor :casted_by
7
- attr_accessor :casted_by_property
8
- end
9
- end
10
- end