Module: Lunetas::Candy::Initialization::InstanceMethods
- Defined in:
- lib/lunetas/candy/initialization.rb
Instance Attribute Summary collapse
-
#lunetas_headers ⇒ Object
readonly
Holds the current headers for the response.
-
#lunetas_url_instance_params ⇒ Object
readonly
The url parameters hold by the instance.
-
#url ⇒ Object
readonly
The matched url-regex for this resource.
Instance Method Summary collapse
-
#initialize(env, url_matches) ⇒ Object
The initialization of a class that includes a Candy, should be done with rack environment and the url matches from its regular expression.
Instance Attribute Details
#lunetas_headers ⇒ Object (readonly)
Holds the current headers for the response.
8 9 10 |
# File 'lib/lunetas/candy/initialization.rb', line 8 def lunetas_headers @lunetas_headers end |
#lunetas_url_instance_params ⇒ Object (readonly)
The url parameters hold by the instance.
6 7 8 |
# File 'lib/lunetas/candy/initialization.rb', line 6 def lunetas_url_instance_params @lunetas_url_instance_params end |
#url ⇒ Object (readonly)
The matched url-regex for this resource.
4 5 6 |
# File 'lib/lunetas/candy/initialization.rb', line 4 def url @url end |
Instance Method Details
#initialize(env, url_matches) ⇒ Object
The initialization of a class that includes a Candy, should be done with rack environment and the url matches from its regular expression. It will register all the passed url parameters from #matches as new instance variables.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lunetas/candy/initialization.rb', line 17 def initialize(env, url_matches) @req = Rack::Request.new(env) @lunetas_headers = {} @lunetas_url_instance_params = url_matches @url = @lunetas_url_instance_params.shift begin self.class.lunetas_url_params.each_with_index do |option, index| instance_variable_set "@#{option}", url_param(index) end # Provide an authentication method. Probably a method # from the Lunetas::Bag. # authenticate! # rescue Lunetas::Error::AuthenticationError # @_error = Lunetas::Error::AuthenticationError end end |