Class: Dao::Result

Inherits:
Map
  • Object
show all
Defined in:
lib/dao/result.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ Result

Returns a new instance of Result.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/dao/result.rb', line 3

def initialize(*args, &block)
  options = Dao.options_for!(args)

  self.path = args.shift || options[:path] || Path.default
  self.route = options[:route] || Route.default
  self.mode = options[:mode] || Mode.default
  self.status = options[:status] || Status.default
  self.errors = options[:errors] || Errors.new
  self.params = options[:params] || Params.new
  self.data = options[:data] || Data.new

  params.result = self
  params.path = self.path
  params.status = self.status
  params.errors = self.errors
end

Instance Method Details

#error!Object



20
21
22
# File 'lib/dao/result.rb', line 20

def error!
  raise Dao::Error::Result.for(self)
end

#formObject



40
41
42
# File 'lib/dao/result.rb', line 40

def form
  params.form
end

#inspectObject

look good for inspect



26
27
28
# File 'lib/dao/result.rb', line 26

def inspect
  ::JSON.pretty_generate(self, :max_nesting => 0)
end