Class: FakeData::Structure

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_data/structure.rb

Constant Summary collapse

FAKER_MATCHER =
/\%{(?<content>.*?)\}/

Class Method Summary collapse

Class Method Details

.object_to_lambda(object) ⇒ Object

Makes lambda from object



7
8
9
10
11
12
13
# File 'lib/fake_data/structure.rb', line 7

def object_to_lambda(object)
  source_to_lambda(
    object_to_source(
      object
    )
  )
end

.object_to_source(object) ⇒ Object

For debug



21
22
23
24
25
26
27
28
29
# File 'lib/fake_data/structure.rb', line 21

def object_to_source(object)
  result = ""

  result << "lambda do\n"
  result << build_faker_element(object)
  result << "\nend"

  result
end

.source_to_lambda(string) ⇒ Object

For debug



16
17
18
# File 'lib/fake_data/structure.rb', line 16

def source_to_lambda(string)
  eval(string)
end