Class: Dao::Params

Inherits:
Map
  • Object
show all
Includes:
Validations
Defined in:
lib/dao/params.rb

Constant Summary

Constants included from Validations

Validations::ClassMethods, Validations::InstanceMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validations

add, included

Constructor Details

#initialize(*args, &block) ⇒ Params

Returns a new instance of Params.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dao/params.rb', line 18

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

  @path = args.shift || options[:path] || Path.default
  @route = options[:route] || Route.default
  @form = options[:form] || Form.for(self)

  update(options[:params]) if options[:params]

  super
end

Instance Attribute Details

#formObject

Returns the value of attribute form.



16
17
18
# File 'lib/dao/params.rb', line 16

def form
  @form
end

#pathObject

instance methods



14
15
16
# File 'lib/dao/params.rb', line 14

def path
  @path
end

#routeObject

Returns the value of attribute route.



15
16
17
# File 'lib/dao/params.rb', line 15

def route
  @route
end

Instance Method Details

#attributesObject



30
31
32
# File 'lib/dao/params.rb', line 30

def attributes
  self
end

#inspectObject

look good for inspect



38
39
40
# File 'lib/dao/params.rb', line 38

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

#update(*args, &block) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/dao/params.rb', line 47

def update(*args, &block)
  if args.size==1 and args.first.respond_to?(:to_dao)
    to_dao = args.first.to_dao
    return super(to_dao)
  end
  super
end