class MdNotes::User

User Model.

Attributes

created_at[RW]

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

email[RW]

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

id[RW]

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

name[RW]

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

updated_at[RW]

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

Public Class Methods

from_hash(hash) click to toggle source

Creates an instance of the object from a hash.

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

  # Extract variables from the hash.
  id = hash['id']
  name = hash['name']
  email = hash['email']
  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.
  User.new(id,
           name,
           email,
           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/user.rb, line 30
def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['name'] = 'name'
  @_hash['email'] = 'email'
  @_hash['created_at'] = 'created_at'
  @_hash['updated_at'] = 'updated_at'
  @_hash
end
new(id = nil, name = nil, email = nil, created_at = nil, updated_at = nil, additional_properties = {}) click to toggle source
# File lib/md_notes/models/user.rb, line 40
def initialize(id = nil,
               name = nil,
               email = nil,
               created_at = nil,
               updated_at = nil,
               additional_properties = {})
  @id = id
  @name = name
  @email = email
  @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