algebrick 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/algebrick.rb +12 -10
- 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: f09b0832f9a5c2edf4405f13da8043c747386e1d
|
4
|
+
data.tar.gz: 843e5ebce9cf043aad4ef00ca7392c4b67b14c2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fea697e5a2e76357ec555c439b8de4743de67aed5c22b45bdae7195c876583165ba670e2daee57419790d0601606bd3f440cbc9987692c3a7b6385dd9ab1f782
|
7
|
+
data.tar.gz: 9e27f6e488fa44b8fe1e6026396a610da4597b9b2030ac4303456b65703ae6d81b5672855a15afaef40c9b6845de2abd9b3f1d44a6c54c67a48c79a55427cda1
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
data/lib/algebrick.rb
CHANGED
@@ -606,15 +606,13 @@ module Algebrick
|
|
606
606
|
alias_method :all_readers, :all_field_readers
|
607
607
|
end
|
608
608
|
|
609
|
-
class
|
609
|
+
class OuterShell
|
610
610
|
include Shortcuts
|
611
611
|
|
612
|
-
def
|
612
|
+
def initialize(&block)
|
613
613
|
instance_eval &block
|
614
614
|
end
|
615
615
|
end
|
616
|
-
|
617
|
-
OuterShell = OuterShellImpl.new
|
618
616
|
end
|
619
617
|
|
620
618
|
def self.type(&block)
|
@@ -630,7 +628,7 @@ module Algebrick
|
|
630
628
|
end
|
631
629
|
|
632
630
|
def self.types(&block)
|
633
|
-
DSL::OuterShell.
|
631
|
+
DSL::OuterShell.new &block
|
634
632
|
end
|
635
633
|
|
636
634
|
module Matchers
|
@@ -695,8 +693,7 @@ module Algebrick
|
|
695
693
|
end
|
696
694
|
|
697
695
|
def assigns
|
698
|
-
|
699
|
-
children.inject(mine) { |assigns, child| assigns + child.assigns }.tap do
|
696
|
+
collect_assigns.tap do
|
700
697
|
return yield *assigns if block_given?
|
701
698
|
end
|
702
699
|
end
|
@@ -733,6 +730,11 @@ module Algebrick
|
|
733
730
|
|
734
731
|
private
|
735
732
|
|
733
|
+
def collect_assigns
|
734
|
+
mine = @assign ? [@value] : []
|
735
|
+
children.inject(mine) { |assigns, child| assigns + child.assigns }
|
736
|
+
end
|
737
|
+
|
736
738
|
def matchable!(obj)
|
737
739
|
raise ArgumentError, 'object does not respond to :===' unless obj.respond_to? :===
|
738
740
|
obj
|
@@ -802,15 +804,15 @@ module Algebrick
|
|
802
804
|
super.select &:matched?
|
803
805
|
end
|
804
806
|
|
805
|
-
|
807
|
+
private
|
808
|
+
|
809
|
+
def collect_assigns
|
806
810
|
super.tap do |assigns|
|
807
811
|
missing = assigns_size - assigns.size
|
808
812
|
assigns.push(*::Array.new(missing))
|
809
813
|
end
|
810
814
|
end
|
811
815
|
|
812
|
-
private
|
813
|
-
|
814
816
|
def assigns_size
|
815
817
|
# TODO is it efficient?
|
816
818
|
super_children.map { |ch| ch.assigns.size }.max
|