class MdNotes::Note

Note Model.

Attributes

body[RW]

TODO: Write general description for this method @return [String]

created_at[RW]

TODO: Write general description for this method @return [String]

id[RW]

TODO: Write general description for this method @return [Long]

title[RW]

TODO: Write general description for this method @return [String]

updated_at[RW]

TODO: Write general description for this method @return [String]

user_id[RW]

TODO: Write general description for this method @return [Long]

Public Class Methods

from_hash(hash) click to toggle source

Creates an instance of the object from a hash.

# File lib/md_notes/models/note.rb, line 66
def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash['id']
  title = hash['title']
  body = hash['body']
  user_id = hash['user_id']
  created_at = hash['created_at']
  updated_at = hash['updated_at']

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  Note.new(id,
           title,
           body,
           user_id,
           created_at,
           updated_at,
           hash)
end
names() click to toggle source

A mapping from model property names to API property names.

# File lib/md_notes/models/note.rb, line 34
def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['title'] = 'title'
  @_hash['body'] = 'body'
  @_hash['user_id'] = 'user_id'
  @_hash['created_at'] = 'created_at'
  @_hash['updated_at'] = 'updated_at'
  @_hash
end
new(id = nil, title = nil, body = nil, user_id = nil, created_at = nil, updated_at = nil, additional_properties = {}) click to toggle source
# File lib/md_notes/models/note.rb, line 45
def initialize(id = nil,
               title = nil,
               body = nil,
               user_id = nil,
               created_at = nil,
               updated_at = nil,
               additional_properties = {})
  @id = id
  @title = title
  @body = body
  @user_id = user_id
  @created_at = created_at
  @updated_at = updated_at

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end