Module: Lunetas::Candy::Initialization::ClassMethods
- Defined in:
- lib/lunetas/candy/initialization.rb
Instance Attribute Summary collapse
-
#lunetas_content_type ⇒ Object
readonly
Holds the Content Type for this request.
-
#lunetas_regex ⇒ Object
readonly
Holds the Regular Expression for this class.
-
#lunetas_url_params ⇒ Object
readonly
Holds the URL params, this will be created as instance variables when the class is initialized.
Instance Method Summary collapse
-
#matches(regex, *url_params) ⇒ Object
Registers a new regular expression.
-
#set_content_type(content_type) ⇒ Object
Sets the Content Type for this URL.
Instance Attribute Details
#lunetas_content_type ⇒ Object (readonly)
Holds the Content Type for this request.
40 41 42 |
# File 'lib/lunetas/candy/initialization.rb', line 40 def lunetas_content_type @lunetas_content_type end |
#lunetas_regex ⇒ Object (readonly)
Holds the Regular Expression for this class.
42 43 44 |
# File 'lib/lunetas/candy/initialization.rb', line 42 def lunetas_regex @lunetas_regex end |
#lunetas_url_params ⇒ Object (readonly)
Holds the URL params, this will be created as instance variables when the class is initialized.
38 39 40 |
# File 'lib/lunetas/candy/initialization.rb', line 38 def lunetas_url_params @lunetas_url_params end |
Instance Method Details
#matches(regex, *url_params) ⇒ Object
Registers a new regular expression. Will add it to the Lunetas::Bag. Will convert the regex to a Regular Expression, if passing a String. It also receives the instance variables for the matches of the regex.
58 59 60 61 62 63 64 65 66 |
# File 'lib/lunetas/candy/initialization.rb', line 58 def matches(regex, *url_params) @lunetas_content_type = 'text/html' @lunetas_regex = regex unless Regexp === lunetas_regex @lunetas_regex = Regexp.new(regex) end @lunetas_url_params = url_params Lunetas::Bag.register(lunetas_regex, self) end |
#set_content_type(content_type) ⇒ Object
Sets the Content Type for this URL. Defaults to text/html.
70 71 72 |
# File 'lib/lunetas/candy/initialization.rb', line 70 def set_content_type(content_type) @lunetas_content_type = content_type end |