Class: SPModule

Inherits:
Object
  • Object
show all
Defined in:
lib/shiftplanning/request/sp_module.rb

Overview

Copyright © 2013 Kyle Richardson

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_module = '', _method = '', _params = {}, supported_methods = %w(GET),, required_params = {:GET => []}) ⇒ SPModule

Constructor **********************************



28
29
30
31
32
33
34
# File 'lib/shiftplanning/request/sp_module.rb', line 28

def initialize _module = '', _method = '', _params = {}, supported_methods = %w(GET), required_params = {:GET => []}
  @supported_methods = supported_methods
  @required_params = required_params
  @params = _params
  @module = _module
  @method = _method 
end

Instance Attribute Details

#methodObject

Returns the value of attribute method.



24
25
26
# File 'lib/shiftplanning/request/sp_module.rb', line 24

def method
  @method
end

#moduleObject (readonly)

Setup getters and setters



23
24
25
# File 'lib/shiftplanning/request/sp_module.rb', line 23

def module
  @module
end

#paramsObject

Returns the value of attribute params.



24
25
26
# File 'lib/shiftplanning/request/sp_module.rb', line 24

def params
  @params
end

#supported_methodsObject (readonly)

Setup getters and setters



23
24
25
# File 'lib/shiftplanning/request/sp_module.rb', line 23

def supported_methods
  @supported_methods
end

Instance Method Details

#required_params(method) ⇒ Object

**********************************



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/shiftplanning/request/sp_module.rb', line 37

def required_params method
  case method.class.to_s
  when 'Symbol'
    method = method.to_s.upcase.to_sym
  when 'String'
    method = method.upcase.to_sym
  else
    raise %q('method' should be a String or a Symbol)
  end
  
  case method
  when :GET
    @required_params[:GET]||'Unsupported method'
  when :CREATE
    @required_params[:CREATE]||'Unsupported method' 
  when :UPDATE
    @required_params[:UPDATE]||'Unsupported method'
  when :DELETE
    @required_params[:DELETE]||'Unsupported method'
  end
end