Module: Cyberweb::Sinatra::CustomExtensions
Overview
Cyberweb::Sinatra::CustomExtensions
Instance Method Summary
collapse
Instance Method Details
#abr(route = '/view', hash_to_pass = {}) ⇒ Object
71
72
73
74
75
76
|
# File 'lib/cyberweb/sinatra/custom_extensions.rb', line 71
def abr(
route = '/view',
hash_to_pass = {}
)
a(route, hash_to_pass)+br
end
|
#are_we_using_sinatra? ⇒ Boolean
Also known as:
use_sinatra?
#
are_we_using_sinatra?
This must return true by “simple logic” - after all we are specifically using custom extensions for sinatra, so we will assume that the user wants a sinatra-like web-behaviour as well.
#
138
139
140
|
# File 'lib/cyberweb/sinatra/custom_extensions.rb', line 138
def are_we_using_sinatra?
true
end
|
#merge_interface(i, prepend_this_to_the_route = '/', namespace_to_use = nil, debug = false) ⇒ Object
Also known as:
merge_routes
#
Cyberweb::Sinatra::CustomExtensions.merge_interface
This method can be used to merge interfaces or routes into the sinatra application at hand.
The last argument is the namespace we want to use, such as PdfParadise.
#
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/cyberweb/sinatra/custom_extensions.rb', line 87
def merge_interface(
i, prepend_this_to_the_route = '/',
namespace_to_use = nil, debug = false
)
i.each {|entry|
if namespace_to_use
object_embeddable_interface = namespace_to_use.send(:embeddable_interface)
end
target = "#{prepend_this_to_the_route}#{entry}".squeeze('/')
if debug
puts "The target that will be added next is: #{target}"
end
get(target) {
_ = entry.to_s.dup
if _.end_with?('/') or _.end_with?('*')
_.delete!('/')
_.delete!('*')
_ << '_with_arguments'
end
name_of_the_method = "return_sinatra_#{_}"
if _.include? '_with_arguments'
object_embeddable_interface.send(
name_of_the_method, self.web_params_as_string?
)
else object_embeddable_interface.send(
name_of_the_method
)
end
}
}
end
|
#not_yet_implemented ⇒ Object
#
not_yet_implemented
This can be added as a placeholder for future changes.
#
147
148
149
150
151
|
# File 'lib/cyberweb/sinatra/custom_extensions.rb', line 147
def not_yet_implemented
p(
"Not yet implemented."
)
end
|
#query_string? ⇒ Boolean
Also known as:
web_params_as_string?, params_as_string?
#
query_string?
This method will return a String.
I recommend to use web_params_as_string? though.
#
39
40
41
42
43
44
45
|
# File 'lib/cyberweb/sinatra/custom_extensions.rb', line 39
def query_string?
_ = web_params?.dup
if _.is_a? Array
_ = _.join(' ').strip
end
return _
end
|
#temp_dir? ⇒ Boolean
156
157
158
|
# File 'lib/cyberweb/sinatra/custom_extensions.rb', line 156
def temp_dir?
'/tmp/'
end
|
#web_params? ⇒ Boolean
Also known as:
web_params, splat?
#
web_params?
Return the parameters for sinatra here through this method.
#
53
54
55
|
# File 'lib/cyberweb/sinatra/custom_extensions.rb', line 53
def web_params?
params[:splat]
end
|