Class: Tracksperanto::Parameters::Parameter
- Inherits:
-
Object
- Object
- Tracksperanto::Parameters::Parameter
- Includes:
- BlockInit
- Defined in:
- lib/tracksperanto/parameters.rb
Instance Attribute Summary collapse
-
#cast ⇒ Object
The cast for the attribute (like :int or :float).
-
#default ⇒ Object
Default value of the attribute.
-
#desc ⇒ Object
Attribute description for the UI.
-
#name ⇒ Object
The name of the paramenter and the related object attribute.
-
#required ⇒ Object
Whether the attribute is required.
Instance Method Summary collapse
Methods included from BlockInit
Instance Attribute Details
#cast ⇒ Object
The cast for the attribute (like :int or :float)
21 22 23 |
# File 'lib/tracksperanto/parameters.rb', line 21 def cast @cast end |
#default ⇒ Object
Default value of the attribute
18 19 20 |
# File 'lib/tracksperanto/parameters.rb', line 18 def default @default end |
#desc ⇒ Object
Attribute description for the UI
24 25 26 |
# File 'lib/tracksperanto/parameters.rb', line 24 def desc @desc end |
#name ⇒ Object
The name of the paramenter and the related object attribute
12 13 14 |
# File 'lib/tracksperanto/parameters.rb', line 12 def name @name end |
#required ⇒ Object
Whether the attribute is required
15 16 17 |
# File 'lib/tracksperanto/parameters.rb', line 15 def required @required end |
Instance Method Details
#apply_to(to_class) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/tracksperanto/parameters.rb', line 26 def apply_to(to_class) to_class.send(:attr_accessor, name) if cast cast_call = "cast_to_#{cast}" to_class.send(cast_call, name) end if required to_class.safe_reader name end end |