Class: Yoda::Store::Objects::Overload

Inherits:
Object
  • Object
show all
Defined in:
lib/yoda/store/objects/overload.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, parameters: [], document: '', tag_list: []) ⇒ Overload

Returns a new instance of Overload.

Parameters:

  • name (String)
  • parameters (Array<(String, String)>) (defaults to: [])
  • document (String) (defaults to: '')
  • tag_list (Array<Tag>) (defaults to: [])


32
33
34
35
36
37
# File 'lib/yoda/store/objects/overload.rb', line 32

def initialize(name:, parameters: [], document: '', tag_list: [])
  @name = name
  @parameters = parameters
  @document = document
  @tag_list = tag_list
end

Instance Attribute Details

#documentString? (readonly)

Returns:

  • (String, nil)


23
24
25
# File 'lib/yoda/store/objects/overload.rb', line 23

def document
  @document
end

#nameString (readonly)

Returns:

  • (String)


17
18
19
# File 'lib/yoda/store/objects/overload.rb', line 17

def name
  @name
end

#parametersArray<(String, String)> (readonly)

Returns:

  • (Array<(String, String)>)


20
21
22
# File 'lib/yoda/store/objects/overload.rb', line 20

def parameters
  @parameters
end

#tag_listArray<Tag> (readonly)

Returns:



26
27
28
# File 'lib/yoda/store/objects/overload.rb', line 26

def tag_list
  @tag_list
end

Class Method Details

.json_creatable?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/yoda/store/objects/overload.rb', line 6

def json_creatable?
  true
end

.json_create(params) ⇒ Object

Parameters:

  • params (Hash)


11
12
13
# File 'lib/yoda/store/objects/overload.rb', line 11

def json_create(params)
  new(**params.map { |k, v| [k.to_sym, v] }.select { |(k, v)| %i(name tag_list document parameters).include?(k) }.to_h)
end

Instance Method Details

#to_hHash

Returns:

  • (Hash)


40
41
42
# File 'lib/yoda/store/objects/overload.rb', line 40

def to_h
  { name: name, parameters: parameters, document: document, tag_list: tag_list }
end

#to_json(_mode = nil) ⇒ String

Returns:

  • (String)


45
46
47
# File 'lib/yoda/store/objects/overload.rb', line 45

def to_json(_mode = nil)
  to_h.merge(json_class: self.class.name).to_json
end