cot 0.4.1 → 0.4.2

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: 80b8c78bd9fd2bedc92cfd64079c168662910a8b
4
- data.tar.gz: d9f342d772816b891a3fa12d5db8a468e1bd0a58
3
+ metadata.gz: aa8903cd5e703422db57575411b464c7ec5b156a
4
+ data.tar.gz: 193b05ad13a36ac2d81a74637293e475c3a30ca2
5
5
  SHA512:
6
- metadata.gz: b6e988adce02b522f15553a385ecef83d990a08b2ae9b8065fdfc0fd3ce0089ec3a9f35c93f1719e46d936383f6300adcb6c0dfd2f335fb137fc40d181d94b21
7
- data.tar.gz: 5f701c6224a24df45a82eee77fd87bf6fcb3a55788e37836bce51dec8988150dd7eccbca623764b1369d0eb0c996665df43b533c034e2509aea93e2c2fbb7589
6
+ metadata.gz: 43371ff3f3487036d52a1a20b77124d2343d481086f28bf4fb66ca9931502e7c404bf9581eed999c0955cf5f15c22271e3e34fa9e859e6756e38a495a57a718a
7
+ data.tar.gz: cb310e1923f79143151107a448a209d839fadb669f07d816428740ecd157402209a81a80292795acce9eafd5c6504ffe3a84a834857d18543cb942e3715da10f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cot (0.4.0)
4
+ cot (0.4.1)
5
5
  activemodel
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -39,6 +39,7 @@ thingy = ExampleObject.new(id: :my_id, name: 'awesome name', createdOn: Time.now
39
39
  thingy.id # 5
40
40
  thingy.name # awesome name
41
41
  ExampleObject.types.first # 1
42
+ ExampleObject.types[:third] # 3
42
43
  thingy.types.fourth # 4
43
44
  thingy.item # NestedClass instance
44
45
  thingy.item.foo # 'this is nested.foo'
@@ -73,6 +74,7 @@ Frame provides some helpful methods:
73
74
  - search\_property adds the parameter to the search mapping. It takes an optional from argument which inidates the property has an alternate key in the incoming/outgoing data.
74
75
  - enum takes a name and a block
75
76
  - Enums are defined on the instances and the class
77
+ - Enum defines a method for each entry and also allows readonly hash access
76
78
  - The block expects a series of entries to be declared
77
79
  - enum starts counting at 1 by default
78
80
  - Each entry will have the value of 1 higher than the previous by default
@@ -19,5 +19,9 @@ module Cot
19
19
  @num = value + 1
20
20
  used[value] = name
21
21
  end
22
+
23
+ def [](key)
24
+ send key
25
+ end
22
26
  end
23
27
  end
@@ -1,3 +1,3 @@
1
1
  module Cot
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
3
3
  end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+ describe Cot::Enum do
3
+ before :each do
4
+ class TestObject < Cot::Frame
5
+ enum :types do
6
+ entry :first
7
+ entry :third, value: 3
8
+ entry :fourth
9
+ end
10
+ end
11
+ @foo = TestObject.new
12
+ end
13
+ subject(:enum) { @foo.types }
14
+ it 'defines methods for each entry' do
15
+ expect(enum.first).to eq 1
16
+ expect(enum.third).to eq 3
17
+ expect(enum.fourth).to eq 4
18
+ end
19
+
20
+ it 'allows hash access' do
21
+ expect(enum).to respond_to :[]
22
+ expect(enum[:first]).to eq 1
23
+ expect(enum[:third]).to eq 3
24
+ expect(enum[:fourth]).to eq 4
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Henrich
@@ -136,6 +136,7 @@ files:
136
136
  - lib/cot/rspec/matchers.rb
137
137
  - lib/cot/version.rb
138
138
  - spec/lib/cot/collection_spec.rb
139
+ - spec/lib/cot/enum_spec.rb
139
140
  - spec/lib/cot/frame_spec.rb
140
141
  - spec/spec_helper.rb
141
142
  homepage: http://github.com/crimsonknave/cot
@@ -164,5 +165,6 @@ specification_version: 4
164
165
  summary: Simplifies creating models for rest based resources
165
166
  test_files:
166
167
  - spec/lib/cot/collection_spec.rb
168
+ - spec/lib/cot/enum_spec.rb
167
169
  - spec/lib/cot/frame_spec.rb
168
170
  - spec/spec_helper.rb