Class: ExampleTodoListComponent::TodoItemResource

Inherits:
Object
  • Object
show all
Includes:
JsonSchemaView::JsonSchemaDefinable
Defined in:
lib/json_schema_view/rails/generators/install/templates/example/todo_item_resource.rb

Overview

This is an example definition of a resource.

A class that includes JsonSchemaView::JsonSchemaDefinable can generate its JSON Schema and it can be used as a type in another resource’s property.

Instance Method Summary collapse

Methods included from JsonSchemaView::JsonWorldExtensions::Validatable

#validate_json!

Methods included from JsonSchemaView::JsonWorldExtensions::CompactOptionalProperties

#properties

Constructor Details

#initialize(todo_item) ⇒ TodoItemResource

Returns a new instance of TodoItemResource.

Parameters:

  • todo_item (Hash)

    A todo item ({ name: String, done: Boolean, note: String or nil }).



33
34
35
# File 'lib/json_schema_view/rails/generators/install/templates/example/todo_item_resource.rb', line 33

def initialize(todo_item)
  @todo_item = todo_item
end

Instance Method Details

#doneBoolean

Returns Whether the TODO item is done or not.

Returns:

  • (Boolean)

    Whether the TODO item is done or not.



43
44
45
# File 'lib/json_schema_view/rails/generators/install/templates/example/todo_item_resource.rb', line 43

def done
  @todo_item[:done]
end

#noteObject

Parameters:

  • note (String, nil)

    The additional description of TODO item.



48
49
50
# File 'lib/json_schema_view/rails/generators/install/templates/example/todo_item_resource.rb', line 48

def note
  @todo_item[:note]
end

#titleString

Returns The title of TODO item.

Returns:

  • (String)

    The title of TODO item.



38
39
40
# File 'lib/json_schema_view/rails/generators/install/templates/example/todo_item_resource.rb', line 38

def title
  @todo_item[:title]
end