Module: Schema::DataStructure

Included in:
Controls::DataStructure::ConfigureDependencies::Example, Controls::DataStructure::Example
Defined in:
lib/schema/data_structure.rb

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 Virtual
    include Schema
    extend Build

    virtual :configure
    virtual :configure_dependencies do
      configure
    end

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

Instance Method Details

#cloneObject



48
49
50
51
52
53
54
55
56
# File 'lib/schema/data_structure.rb', line 48

def clone
  duplicate = deep_copy

  if frozen?
    duplicate.freeze
  end

  duplicate
end

#deep_copyObject Also known as: dup



42
43
44
45
# File 'lib/schema/data_structure.rb', line 42

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