Module: Watirmark::Model::FactoryMethods
- Included in:
- Factory
- Defined in:
- lib/watirmark/models/factory_methods.rb
Instance Attribute Summary collapse
- #default ⇒ Object
-
#included_traits ⇒ Object
Returns the value of attribute included_traits.
- #keys ⇒ Object
-
#model_type_name ⇒ Object
Returns the value of attribute model_type_name.
-
#search ⇒ Object
Returns the value of attribute search.
Instance Method Summary collapse
- #children ⇒ Object
- #defaults(&block) ⇒ Object
- #inherited(klass) ⇒ Object
- #keywords(*args) ⇒ Object
- #model(*models) ⇒ Object
- #model_type(c_name) ⇒ Object
- #search_term(&block) ⇒ Object
- #traits(*names) ⇒ Object
Instance Attribute Details
#default ⇒ Object
15 16 17 |
# File 'lib/watirmark/models/factory_methods.rb', line 15 def default @default ||= DefaultValues.new end |
#included_traits ⇒ Object
Returns the value of attribute included_traits.
4 5 6 |
# File 'lib/watirmark/models/factory_methods.rb', line 4 def included_traits @included_traits end |
#keys ⇒ Object
19 20 21 |
# File 'lib/watirmark/models/factory_methods.rb', line 19 def keys @keys ||= [] end |
#model_type_name ⇒ Object
Returns the value of attribute model_type_name.
4 5 6 |
# File 'lib/watirmark/models/factory_methods.rb', line 4 def model_type_name @model_type_name end |
#search ⇒ Object
Returns the value of attribute search.
4 5 6 |
# File 'lib/watirmark/models/factory_methods.rb', line 4 def search @search end |
Instance Method Details
#children ⇒ Object
27 28 29 |
# File 'lib/watirmark/models/factory_methods.rb', line 27 def children @children ||= [] end |
#defaults(&block) ⇒ Object
23 24 25 |
# File 'lib/watirmark/models/factory_methods.rb', line 23 def defaults(&block) default.instance_exec &block end |
#inherited(klass) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/watirmark/models/factory_methods.rb', line 7 def inherited(klass) unless self == Factory add_keywords_to_subclass klass add_defaults_to_subclass klass add_traits_to_subclass klass end end |
#keywords(*args) ⇒ Object
49 50 51 52 53 |
# File 'lib/watirmark/models/factory_methods.rb', line 49 def keywords(*args) @keys ||= [] @keys += [*args].flatten @keys = @keys.uniq end |
#model(*models) ⇒ Object
31 32 33 34 35 |
# File 'lib/watirmark/models/factory_methods.rb', line 31 def model *models models.each { |model| raise Watirmark::ModelCreationError unless Class === model } @children = children + models @children.uniq! end |
#model_type(c_name) ⇒ Object
37 38 39 |
# File 'lib/watirmark/models/factory_methods.rb', line 37 def model_type(c_name) @model_type_name = c_name end |
#search_term(&block) ⇒ Object
41 42 43 |
# File 'lib/watirmark/models/factory_methods.rb', line 41 def search_term &block @search = block end |
#traits(*names) ⇒ Object
45 46 47 |
# File 'lib/watirmark/models/factory_methods.rb', line 45 def traits(*names) @included_traits = [*names].flatten end |