Class: MiniResource
- Inherits:
-
Object
- Object
- MiniResource
- Defined in:
- lib/sawa/MiniResource.rb
Instance Method Summary collapse
-
#initialize(row, sheet) ⇒ MiniResource
constructor
A new instance of MiniResource.
- #resource_desc ⇒ Object
- #resource_httpM ⇒ Object
- #resource_islist ⇒ Object
- #resource_method ⇒ Object
- #resource_param_full ⇒ Object
- #resource_param_type ⇒ Object
- #resource_param_value ⇒ Object
- #resource_path ⇒ Object
- #resource_process ⇒ Object
- #resource_role ⇒ Object
Constructor Details
#initialize(row, sheet) ⇒ MiniResource
Returns a new instance of MiniResource.
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/sawa/MiniResource.rb', line 2 def initialize(row, sheet) @row = row @sheet = sheet @idx_method = 1 @idx_process = 2 @idx_role = 3 @idx_desc = 4 @idx_islist = 5 @idx_param = 6 @idx_path = 7 @idx_httpM = 8 end |
Instance Method Details
#resource_desc ⇒ Object
31 32 33 |
# File 'lib/sawa/MiniResource.rb', line 31 def resource_desc @row[@idx_desc] end |
#resource_httpM ⇒ Object
96 97 98 |
# File 'lib/sawa/MiniResource.rb', line 96 def resource_httpM @row[@idx_httpM] end |
#resource_islist ⇒ Object
35 36 37 |
# File 'lib/sawa/MiniResource.rb', line 35 def resource_islist @row[@idx_islist] == "1" end |
#resource_method ⇒ Object
15 16 17 |
# File 'lib/sawa/MiniResource.rb', line 15 def resource_method @row[@idx_method] end |
#resource_param_full ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/sawa/MiniResource.rb', line 69 def resource_param_full vals = [] prms = @row[@idx_param].split(",") prms.map do |prm| if prm.strip == "@query" vals.push("MiniQuery query") elsif prm.strip == "@role" vals.push("@Auth OperatorRole role") elsif prm.strip == "@obj" vals.push("#{@sheet.model_name} obj") else arr = prm.split(" ") s = arr[arr.length - 1] if @row[@idx_path].include?("#{s}") vals.push("@PathParam(\"#{s}\") #{prm.strip}") else vals.push("@QueryParam(\"#{s}\") #{prm.strip}") end end end vals.join(",") end |
#resource_param_type ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/sawa/MiniResource.rb', line 39 def resource_param_type vals = [] prms = @row[@idx_param].split(",") prms.map do |prm| if prm.strip == "@query" vals.push("MiniQuery query") elsif prm.strip == "@role" vals.push("OperatorRole role") elsif prm.strip == "@obj" vals.push("#{@sheet.model_name} obj") else vals.push(prm) end end vals.join(",") end |
#resource_param_value ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/sawa/MiniResource.rb', line 56 def resource_param_value vals = [] prms = @row[@idx_param].split(",") prms.map do |prm| tmp = prm.split(" ") vals.push(tmp[tmp.length - 1].gsub(/@/, '')) end if !@row[@idx_process].start_with?("super.") vals.push("this") end vals.join(",") end |
#resource_path ⇒ Object
92 93 94 |
# File 'lib/sawa/MiniResource.rb', line 92 def resource_path @row[@idx_path] end |
#resource_process ⇒ Object
19 20 21 |
# File 'lib/sawa/MiniResource.rb', line 19 def resource_process @row[@idx_process] end |
#resource_role ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/sawa/MiniResource.rb', line 23 def resource_role if @row[@idx_role] == nil or @row[@idx_role] == "" nil else "\"" + @row[@idx_role].split(",").join(",") + "\"" end end |