Class: MiniResource

Inherits:
Object
  • Object
show all
Defined in:
lib/sawa/MiniResource.rb

Instance Method Summary collapse

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_descObject



31
32
33
# File 'lib/sawa/MiniResource.rb', line 31

def resource_desc
  @row[@idx_desc]
end

#resource_httpMObject



96
97
98
# File 'lib/sawa/MiniResource.rb', line 96

def resource_httpM
  @row[@idx_httpM]
end

#resource_islistObject



35
36
37
# File 'lib/sawa/MiniResource.rb', line 35

def resource_islist
  @row[@idx_islist] == "1"
end

#resource_methodObject



15
16
17
# File 'lib/sawa/MiniResource.rb', line 15

def resource_method
  @row[@idx_method]
end

#resource_param_fullObject



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_typeObject



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_valueObject



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_pathObject



92
93
94
# File 'lib/sawa/MiniResource.rb', line 92

def resource_path
  @row[@idx_path]
end

#resource_processObject



19
20
21
# File 'lib/sawa/MiniResource.rb', line 19

def resource_process
  @row[@idx_process]
end

#resource_roleObject



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