Class: MdNotes::Note
Overview
Note Model.
Instance Attribute Summary collapse
-
#body ⇒ String
TODO: Write general description for this method.
-
#created_at ⇒ String
TODO: Write general description for this method.
-
#id ⇒ Long
TODO: Write general description for this method.
-
#title ⇒ String
TODO: Write general description for this method.
-
#updated_at ⇒ String
TODO: Write general description for this method.
-
#user_id ⇒ Long
TODO: Write general description for this method.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(id = nil, title = nil, body = nil, user_id = nil, created_at = nil, updated_at = nil, additional_properties = {}) ⇒ Note
constructor
A new instance of Note.
Methods inherited from BaseModel
#method_missing, #respond_to_missing?, #to_hash, #to_json
Constructor Details
#initialize(id = nil, title = nil, body = nil, user_id = nil, created_at = nil, updated_at = nil, additional_properties = {}) ⇒ Note
Returns a new instance of Note.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class MdNotes::BaseModel
Instance Attribute Details
#body ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/md_notes/models/note.rb', line 19 def body @body end |
#created_at ⇒ String
TODO: Write general description for this method
27 28 29 |
# File 'lib/md_notes/models/note.rb', line 27 def created_at @created_at end |
#id ⇒ Long
TODO: Write general description for this method
11 12 13 |
# File 'lib/md_notes/models/note.rb', line 11 def id @id end |
#title ⇒ String
TODO: Write general description for this method
15 16 17 |
# File 'lib/md_notes/models/note.rb', line 15 def title @title end |
#updated_at ⇒ String
TODO: Write general description for this method
31 32 33 |
# File 'lib/md_notes/models/note.rb', line 31 def updated_at @updated_at end |
#user_id ⇒ Long
TODO: Write general description for this method
23 24 25 |
# File 'lib/md_notes/models/note.rb', line 23 def user_id @user_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# 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 ⇒ Object
A mapping from model property names to API property names.
34 35 36 37 38 39 40 41 42 43 |
# 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 |