Module: Watirmark::Model::FactoryMethods

Included in:
Factory
Defined in:
lib/watirmark/models/factory_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#defaultObject



15
16
17
# File 'lib/watirmark/models/factory_methods.rb', line 15

def default
  @default ||= DefaultValues.new
end

#included_traitsObject

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

#keysObject



19
20
21
# File 'lib/watirmark/models/factory_methods.rb', line 19

def keys
  @keys ||= []
end

#model_type_nameObject

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

#searchObject

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

#childrenObject



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