Module: Schema::DataStructure

Defined Under Namespace

Modules: Build

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(cls) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/schema/data_structure.rb', line 3

def self.included(cls)
  cls.class_exec do
    include TemplateMethod
    include Schema
    extend Build

    template_method :configure
    template_method :configure_dependencies do
      configure
    end

    template_method :transform_read do |data|
      transform_in(data)
    end
    template_method :transform_in
  end
end

Instance Method Details

#cloneObject



51
52
53
54
55
56
57
58
59
# File 'lib/schema/data_structure.rb', line 51

def clone
  duplicate = deep_copy

  if frozen?
    duplicate.freeze
  end

  duplicate
end

#deep_copyObject Also known as: dup



45
46
47
48
# File 'lib/schema/data_structure.rb', line 45

def deep_copy
  data = to_h
  self.class.build(data)
end