Module: Oscal::Serializer
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
25 26 27 |
# File 'lib/oscal/serializer.rb', line 25 def self.included(klass) klass.extend(ClassMethods) end |
Instance Method Details
#to_h ⇒ Object
6 7 8 9 10 11 |
# File 'lib/oscal/serializer.rb', line 6 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
13 14 15 |
# File 'lib/oscal/serializer.rb', line 13 def to_json(*args) to_h.to_json(*args) end |
#to_xml(builder) ⇒ Object
21 22 23 |
# File 'lib/oscal/serializer.rb', line 21 def to_xml(builder) raise NotImplementedError, "#{self.class}#to_xml not implemented!" end |
#to_yaml ⇒ Object
17 18 19 |
# File 'lib/oscal/serializer.rb', line 17 def to_yaml to_h.to_yaml end |