horza 0.3.8 → 0.3.9
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 +4 -4
- data/lib/horza/entities/collection.rb +1 -1
- data/spec/active_record_spec.rb +12 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05dec4f4ed4ea42ae1721a8b519496ec70f2a803
|
4
|
+
data.tar.gz: 3fbd9ab81b756c4e4666a5334d7dda52b44a6fca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3afecde1421ecf764dfb2b8ebe1a3f7450526632488fc052376e46c1f0f35d7b3fd8dec25f2465bd3a1db3f65dd3dbef2041064ef7f53c59f03e0f7d88b13179
|
7
|
+
data.tar.gz: 42e7183c12b8733dd2db997ebccb2df9741c3ef5e5dbf5b0f57c7ef01c1f33684b280698594e52ae5c53b57c41c14c30ad8831678474cf8d7e3b8ee958728640
|
@@ -14,7 +14,7 @@ module Horza
|
|
14
14
|
def method_missing(method, &block)
|
15
15
|
if [:length, :size, :empty?, :present?].include? method
|
16
16
|
@collection.send(method)
|
17
|
-
elsif [:first, :last].include? method
|
17
|
+
elsif [:first, :last, :pop].include? method
|
18
18
|
singular_entity(@collection.send(method))
|
19
19
|
elsif [:each, :map, :collect]
|
20
20
|
enum_method(method, &block)
|
data/spec/active_record_spec.rb
CHANGED
@@ -527,7 +527,7 @@ describe Horza do
|
|
527
527
|
|
528
528
|
context '#each' do
|
529
529
|
context 'when name is of ancestry type' do
|
530
|
-
it 'yields a
|
530
|
+
it 'yields a Horza::Entities::Single with each iteration' do
|
531
531
|
subject.each do |member|
|
532
532
|
expect(member.is_a? Horza::Entities::Single).to be true
|
533
533
|
end
|
@@ -537,7 +537,7 @@ describe Horza do
|
|
537
537
|
|
538
538
|
context '#map' do
|
539
539
|
context 'when name is of ancestry type' do
|
540
|
-
it 'yields a
|
540
|
+
it 'yields a Horza::Entities::Single with each iteration, returns array' do
|
541
541
|
map = subject.map(&:id)
|
542
542
|
expect(map.is_a? Array).to be true
|
543
543
|
expect(map.length).to eq 3
|
@@ -547,7 +547,7 @@ describe Horza do
|
|
547
547
|
|
548
548
|
context '#collect' do
|
549
549
|
context 'when name is of ancestry type' do
|
550
|
-
it 'yields a
|
550
|
+
it 'yields a Horza::Entities::Single with each iteration, returns array' do
|
551
551
|
map = subject.collect(&:id)
|
552
552
|
expect(map.is_a? Array).to be true
|
553
553
|
expect(map.length).to eq 3
|
@@ -555,6 +555,15 @@ describe Horza do
|
|
555
555
|
end
|
556
556
|
end
|
557
557
|
|
558
|
+
context '#pop' do
|
559
|
+
context 'when name is of ancestry type' do
|
560
|
+
it 'returns the last collection item as a Horza::Entities::Single' do
|
561
|
+
entity = subject.pop
|
562
|
+
expect(entity.is_a? Horza::Entities::Single).to be true
|
563
|
+
end
|
564
|
+
end
|
565
|
+
end
|
566
|
+
|
558
567
|
context '#singular_entity_class' do
|
559
568
|
context 'when singular entity class does not exist' do
|
560
569
|
let(:dummy_model) { HorzaSpec::DummyModel.create }
|