Class: Stratagem::Model::Containers::Base
- Includes:
- Enumerable
- Defined in:
- lib/stratagem/model/containers/base.rb
Instance Attribute Summary collapse
-
#components ⇒ Object
readonly
Returns the value of attribute components.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#invalid ⇒ Object
readonly
Returns the value of attribute invalid.
-
#missing ⇒ Object
readonly
Returns the value of attribute missing.
-
#parse_trees ⇒ Object
readonly
Returns the value of attribute parse_trees.
Instance Method Summary collapse
- #-(other) ⇒ Object
- #<<(component) ⇒ Object
- #clear ⇒ Object
- #each ⇒ Object
- #export(options = nil) ⇒ Object
- #find ⇒ Object
-
#initialize(app_model) ⇒ Base
constructor
A new instance of Base.
- #map ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(app_model) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 13 |
# File 'lib/stratagem/model/containers/base.rb', line 7 def initialize(app_model) @app_model = app_model @components = Set.new() @parse_trees = {} @invalid = [] @missing = {} end |
Instance Attribute Details
#components ⇒ Object (readonly)
Returns the value of attribute components.
5 6 7 |
# File 'lib/stratagem/model/containers/base.rb', line 5 def components @components end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
5 6 7 |
# File 'lib/stratagem/model/containers/base.rb', line 5 def errors @errors end |
#invalid ⇒ Object (readonly)
Returns the value of attribute invalid.
5 6 7 |
# File 'lib/stratagem/model/containers/base.rb', line 5 def invalid @invalid end |
#missing ⇒ Object (readonly)
Returns the value of attribute missing.
5 6 7 |
# File 'lib/stratagem/model/containers/base.rb', line 5 def missing @missing end |
#parse_trees ⇒ Object (readonly)
Returns the value of attribute parse_trees.
5 6 7 |
# File 'lib/stratagem/model/containers/base.rb', line 5 def parse_trees @parse_trees end |
Instance Method Details
#-(other) ⇒ Object
34 35 36 |
# File 'lib/stratagem/model/containers/base.rb', line 34 def -(other) @components-other end |
#<<(component) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/stratagem/model/containers/base.rb', line 46 def << (component) if (component.kind_of?(Array)) component.each {|e| @components << e e.app_model = @app_model if e.methods_include?(:app_model=) } elsif (component.kind_of?(Exception)) errors << component else @components << component component.app_model = @app_model if component.methods_include?(:app_model=) end end |
#clear ⇒ Object
26 27 28 |
# File 'lib/stratagem/model/containers/base.rb', line 26 def clear @components.clear end |
#each ⇒ Object
38 39 40 |
# File 'lib/stratagem/model/containers/base.rb', line 38 def each @components.each {|e| yield e } end |
#export(options = nil) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/stratagem/model/containers/base.rb', line 15 def export(=nil) @invalid.each {|i| i.invalid = true } components = @components.to_a.map {|c| c.export }.compact components += @invalid.to_a.map {|c| c.export }.compact components end |
#find ⇒ Object
22 23 24 |
# File 'lib/stratagem/model/containers/base.rb', line 22 def find @components.find{|component| yield component } end |
#map ⇒ Object
42 43 44 |
# File 'lib/stratagem/model/containers/base.rb', line 42 def map @components.map {|e| yield e } end |
#size ⇒ Object
30 31 32 |
# File 'lib/stratagem/model/containers/base.rb', line 30 def size @components.size end |