Class: Reflekt::ObjectRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/rules/object_rule.rb

Instance Attribute Summary

Attributes inherited from Rule

#type

Instance Method Summary collapse

Constructor Details

#initializeObjectRule

Returns a new instance of ObjectRule.



6
7
8
9
10
11
# File 'lib/rules/object_rule.rb', line 6

def initialize()
  @type = :object
  @class_type = nil
  # TODO: Populate with meta for each arg.
  @class_args = []
end

Instance Method Details

#randomObject



36
37
38
39
# File 'lib/rules/object_rule.rb', line 36

def random()
  # TODO: Instantiate class with appropriate @class_args metadata.
  eval("#{@class_type}").new()
end

#resultObject



29
30
31
32
33
34
# File 'lib/rules/object_rule.rb', line 29

def result()
  {
    :type => @type,
    :class_type => @class_type
  }
end

#test(value) ⇒ Object

Parameters:

  • value (NilClass)


25
26
27
# File 'lib/rules/object_rule.rb', line 25

def test(value)
  value.class.to_s == @class_type
end

#train(meta) ⇒ Object

Parameters:



16
17
18
19
20
# File 'lib/rules/object_rule.rb', line 16

def train(meta)
  if @class_type.nil?
    @class_type = meta[:class_type]
  end
end