Module: Oscal::Serializer
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
24 25 26 |
# File 'lib/oscal/serializer.rb', line 24 def self.included(klass) klass.extend(ClassMethods) end |
Instance Method Details
#to_h ⇒ Object
5 6 7 8 9 10 |
# File 'lib/oscal/serializer.rb', line 5 def to_h instance_variables.each_with_object({}) do |var, hash| var_name = var.to_s.delete("@") hash[var_name] = instance_variable_get(var) end end |
#to_json(*args) ⇒ Object
12 13 14 |
# File 'lib/oscal/serializer.rb', line 12 def to_json(*args) to_h.to_json(*args) end |
#to_xml(builder) ⇒ Object
20 21 22 |
# File 'lib/oscal/serializer.rb', line 20 def to_xml(builder) raise NotImplementedError, "#{self.class}#to_xml not implemented!" end |
#to_yaml ⇒ Object
16 17 18 |
# File 'lib/oscal/serializer.rb', line 16 def to_yaml to_h.to_yaml end |