Class: Fried::Schema::CreateDefinitionIfMissing

Inherits:
Object
  • Object
show all
Defined in:
lib/fried/schema/create_definition_if_missing.rb

Overview

Creates schema definition if missing

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#get_definitionObject

Returns the value of attribute get_definition.



8
9
10
# File 'lib/fried/schema/create_definition_if_missing.rb', line 8

def get_definition
  @get_definition
end

Class Method Details

.buildObject



10
11
12
13
14
# File 'lib/fried/schema/create_definition_if_missing.rb', line 10

def self.build
  new.tap do |instance|
    instance.get_definition = GetDefinition.build
  end
end

.call(obj) ⇒ Object



16
17
18
19
# File 'lib/fried/schema/create_definition_if_missing.rb', line 16

def self.call(obj)
  instance = build
  instance.(obj)
end

Instance Method Details

#call(obj) ⇒ Definition

Parameters:

Returns:



23
24
25
26
27
# File 'lib/fried/schema/create_definition_if_missing.rb', line 23

def call(obj)
  schema = get_definition.(obj)

  schema || obj.instance_variable_set(:@__fried_schema__, Definition.new)
end