Module: Collection::Controls::Class::Random

Defined in:
lib/collection/controls/class.rb

Class Method Summary collapse

Class Method Details

.example(root: nil) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/collection/controls/class.rb', line 11

def self.example(root: nil)
  root ||= false

  class_name = "Class#{SecureRandom.hex(2).upcase}"

  namespace = namespace(root)

  namespace.const_set(class_name, ::Class.new)
end

.namespace(root) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/collection/controls/class.rb', line 21

def self.namespace(root)
  if root
    Object
  else
    Collection::Controls::Class
  end
end