Class: Prosereflect::Mark::Base
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Prosereflect::Mark::Base
- Defined in:
- lib/prosereflect/mark/base.rb
Constant Summary collapse
- PM_TYPE =
'mark'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Base
constructor
Override initialize to ensure the type is set correctly.
-
#to_h ⇒ Object
Convert to hash for serialization.
Constructor Details
#initialize(options = {}) ⇒ Base
Override initialize to ensure the type is set correctly
38 39 40 41 42 43 44 45 46 |
# File 'lib/prosereflect/mark/base.rb', line 38 def initialize( = {}) super() # Only set the type to PM_TYPE if no type was provided in options self.type = begin [:type] || self.class.const_get(:PM_TYPE) rescue StandardError 'mark' end end |
Class Method Details
.create(attrs = nil) ⇒ Object
24 25 26 27 28 |
# File 'lib/prosereflect/mark/base.rb', line 24 def self.create(attrs = nil) new(type: const_get(:PM_TYPE), attrs: attrs) rescue NameError new(type: 'mark', attrs: attrs) end |
Instance Method Details
#to_h ⇒ Object
Convert to hash for serialization
31 32 33 34 35 |
# File 'lib/prosereflect/mark/base.rb', line 31 def to_h result = { 'type' => type } result['attrs'] = attrs if attrs && !attrs.empty? result end |