Class: Kaya::Custom::Params
- Inherits:
-
Object
- Object
- Kaya::Custom::Params
- Defined in:
- lib/kaya/custom/params.rb
Class Method Summary collapse
Instance Method Summary collapse
- #all_params ⇒ Object
-
#initialize ⇒ Params
constructor
This class is used to provide to user in his code access to the custom params sent from Kaya.
-
#method_missing(param, *args, &block) ⇒ Object
All custom params can be called as methods.
- #raw ⇒ Object
Constructor Details
#initialize ⇒ Params
This class is used to provide to user in his code access to the custom params sent from Kaya
8 9 10 11 12 13 14 15 |
# File 'lib/kaya/custom/params.rb', line 8 def initialize params = ENV || {} @custom_params = if params["kaya_custom_params"] JSON.parse(params["kaya_custom_params"]) else params end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(param, *args, &block) ⇒ Object
All custom params can be called as methods
28 29 30 |
# File 'lib/kaya/custom/params.rb', line 28 def method_missing(param, *args, &block) @custom_params[param.to_s] end |
Class Method Details
.get ⇒ Object
17 18 19 |
# File 'lib/kaya/custom/params.rb', line 17 def self.get self.new end |
Instance Method Details
#all_params ⇒ Object
21 22 23 |
# File 'lib/kaya/custom/params.rb', line 21 def all_params @custom_params end |
#raw ⇒ Object
25 |
# File 'lib/kaya/custom/params.rb', line 25 def raw; all_params; end |