Class: PairKit::JsonSchema::Dsl::ScalarScaffold

Inherits:
Scaffold
  • Object
show all
Defined in:
lib/pair_kit/json_schema/dsl/scaffolds/scalar_scaffold.rb

Instance Method Summary collapse

Methods inherited from Scaffold

wrap

Constructor Details

#initialize(val) ⇒ ScalarScaffold

Returns a new instance of ScalarScaffold.



5
6
7
# File 'lib/pair_kit/json_schema/dsl/scaffolds/scalar_scaffold.rb', line 5

def initialize(val)
  @value = val
end

Instance Method Details

#<<(val) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/pair_kit/json_schema/dsl/scaffolds/scalar_scaffold.rb', line 9

def <<(val)
  if @value
    @value.is_a?(Array) ? @value << val : @value = [@value, val]
  else
    @value = val
  end
end

#to_schemaObject



17
18
19
# File 'lib/pair_kit/json_schema/dsl/scaffolds/scalar_scaffold.rb', line 17

def to_schema
  @value
end