Class: Ant::Server::Nanoservice::Datasource::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/ant/server/nanoservice/datasource/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dataObject

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

Parameters:

  • value

    the value to set the attribute repository to.



28
29
30
# File 'lib/ant/server/nanoservice/datasource/model.rb', line 28

def repository=(value)
  @repository = value
end

Instance Method Details

#createObject



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

#storeObject



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(options)
  @data.to_json(options)
end