Class: ShareWith::ServiceDataType::BasicDataType
- Inherits:
-
Object
- Object
- ShareWith::ServiceDataType::BasicDataType
- Defined in:
- lib/share_with/service_data.rb
Overview
This works as an abstract class to inherit.
Direct Known Subclasses
Boolean, EncodedText, EncodedUrlParam, Integer, PlainText, Reference, Select, StringList
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
- #value(encoding = nil) ⇒ Object
Instance Method Summary collapse
- #attr(attr_value) ⇒ Object
-
#initialize(data) ⇒ BasicDataType
constructor
A new instance of BasicDataType.
- #reset! ⇒ Object
Constructor Details
#initialize(data) ⇒ BasicDataType
Returns a new instance of BasicDataType.
15 16 17 18 19 |
# File 'lib/share_with/service_data.rb', line 15 def initialize(data) @data = data @default = data[:default] @value = @default end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
12 13 14 |
# File 'lib/share_with/service_data.rb', line 12 def label @label end |
#value(encoding = nil) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/share_with/service_data.rb', line 21 def value(encoding = nil) res = @value || @default || "" res = res.send(encoding.to_sym) unless encoding.nil? res end |
Instance Method Details
#attr(attr_value) ⇒ Object
28 29 30 |
# File 'lib/share_with/service_data.rb', line 28 def attr(attr_value) @data[:attr][attr_value] end |
#reset! ⇒ Object
32 33 34 |
# File 'lib/share_with/service_data.rb', line 32 def reset! self.value = @default end |