Class: Schemify::Keyword

Inherits:
Object
  • Object
show all
Defined in:
lib/schemify/keyword.rb

Overview

Represents a keyword in a schema, which can be used to define metadata or properties

Defined Under Namespace

Modules: Builder

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Keyword

Returns a new instance of Keyword.



8
9
10
# File 'lib/schemify/keyword.rb', line 8

def initialize(value)
  @value = value
end

Class Method Details

.json_name(value = nil, dollar_prefix: false) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/schemify/keyword.rb', line 17

def json_name(value = nil, dollar_prefix: false)
  return @json_name if value.nil?

  @json_name = if dollar_prefix
                 "$#{Naming.json_name(value)}"
               else
                 Naming.json_name(value)
               end
end

Instance Method Details

#to_hObject



12
13
14
# File 'lib/schemify/keyword.rb', line 12

def to_h
  { self.class.json_name => @value }
end