Class: ActiveModel::Serializers::Xml::Serializer::Attribute
- Inherits:
-
Object
- Object
- ActiveModel::Serializers::Xml::Serializer::Attribute
- Defined in:
- lib/active_model/serializers/xml.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #decorations ⇒ Object
-
#initialize(name, serializable, value) ⇒ Attribute
constructor
A new instance of Attribute.
Constructor Details
#initialize(name, serializable, value) ⇒ Attribute
Returns a new instance of Attribute.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/active_model/serializers/xml.rb', line 22 def initialize(name, serializable, value) @name, @serializable = name, serializable if value.acts_like?(:time) && value.respond_to?(:in_time_zone) value = value.in_time_zone end @value = value @type = compute_type end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
20 21 22 |
# File 'lib/active_model/serializers/xml.rb', line 20 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
20 21 22 |
# File 'lib/active_model/serializers/xml.rb', line 20 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
20 21 22 |
# File 'lib/active_model/serializers/xml.rb', line 20 def value @value end |
Instance Method Details
#decorations ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/active_model/serializers/xml.rb', line 33 def decorations decorations = {} decorations[:encoding] = 'base64' if type == :binary decorations[:type] = (type == :string) ? nil : type decorations[:nil] = true if value.nil? decorations end |