Class: Ant::Server::Nanoservice::Datasource::Model
- Inherits:
-
Object
- Object
- Ant::Server::Nanoservice::Datasource::Model
- Defined in:
- lib/ant/server/nanoservice/datasource/model.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#repository ⇒ Object
writeonly
Sets the attribute repository.
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(data) ⇒ Model
constructor
A new instance of Model.
- #run_validations! ⇒ Object
- #store ⇒ Object
- #to_json(options) ⇒ Object
Constructor Details
#initialize(data) ⇒ Model
Returns a new instance of Model.
24 25 26 |
# File 'lib/ant/server/nanoservice/datasource/model.rb', line 24 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
7 8 9 |
# File 'lib/ant/server/nanoservice/datasource/model.rb', line 7 def data @data end |
#repository=(value) ⇒ Object (writeonly)
Sets the attribute repository
28 29 30 |
# File 'lib/ant/server/nanoservice/datasource/model.rb', line 28 def repository=(value) @repository = value end |
Instance Method Details
#create ⇒ Object
19 20 21 22 |
# File 'lib/ant/server/nanoservice/datasource/model.rb', line 19 def create run_validations! @repository.create(@data) end |
#run_validations! ⇒ Object
10 11 12 |
# File 'lib/ant/server/nanoservice/datasource/model.rb', line 10 def run_validations! puts 'WARN: model with no validations' end |
#store ⇒ Object
14 15 16 17 |
# File 'lib/ant/server/nanoservice/datasource/model.rb', line 14 def store run_validations! @repository.store(@data) end |
#to_json(options) ⇒ Object
30 31 32 |
# File 'lib/ant/server/nanoservice/datasource/model.rb', line 30 def to_json() @data.to_json() end |