Class: ParamsReady::InputContext
- Inherits:
-
Object
- Object
- ParamsReady::InputContext
- Extended by:
- Forwardable
- Includes:
- Format::Wrapper
- Defined in:
- lib/params_ready/input_context.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Attributes included from Format::Wrapper
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(format, data = {}) ⇒ InputContext
constructor
A new instance of InputContext.
Constructor Details
#initialize(format, data = {}) ⇒ InputContext
Returns a new instance of InputContext.
13 14 15 16 |
# File 'lib/params_ready/input_context.rb', line 13 def initialize(format, data = {}) @format = Format.resolve(format).freeze @data = data.freeze end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/params_ready/input_context.rb', line 9 def data @data end |
Class Method Details
.resolve(unknown) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/params_ready/input_context.rb', line 18 def self.resolve(unknown) case unknown when nil Format.instance(:frontend) when InputContext, Format unknown when Symbol Format.instance(unknown) else raise ParamsReadyError, "Unexpected type for InputContext: #{unknown.class.name}" end end |