Class: ViewSpec::Param
- Inherits:
-
Object
- Object
- ViewSpec::Param
- Includes:
- ActionView::Helpers::SanitizeHelper
- Defined in:
- lib/view_spec/param.rb
Constant Summary collapse
- NO_DEFAULT =
Object.new
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #default ⇒ Object
- #default? ⇒ Boolean
-
#initialize(name, cast_type = nil, value: nil, default: NO_DEFAULT, **type_options) ⇒ Param
constructor
A new instance of Param.
- #to_pair ⇒ Object
- #type ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(name, cast_type = nil, value: nil, default: NO_DEFAULT, **type_options) ⇒ Param
Returns a new instance of Param.
10 11 12 13 14 15 16 |
# File 'lib/view_spec/param.rb', line 10 def initialize(name, cast_type = nil, value: nil, default: NO_DEFAULT, **) @name = name.to_sym @cast_type = cast_type @value = value @default = default = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/view_spec/param.rb', line 8 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/view_spec/param.rb', line 8 def end |
Instance Method Details
#default ⇒ Object
26 27 28 |
# File 'lib/view_spec/param.rb', line 26 def default (@default == NO_DEFAULT) ? nil : @default end |
#default? ⇒ Boolean
30 31 32 |
# File 'lib/view_spec/param.rb', line 30 def default? @default != NO_DEFAULT end |
#to_pair ⇒ Object
34 35 36 |
# File 'lib/view_spec/param.rb', line 34 def to_pair [name, value] end |
#type ⇒ Object
22 23 24 |
# File 'lib/view_spec/param.rb', line 22 def type @type ||= Type.for(@cast_type, **) end |
#value ⇒ Object
18 19 20 |
# File 'lib/view_spec/param.rb', line 18 def value type.cast(raw_value) end |