Class: Glossarist::Designation::Base
- Includes:
- Utilities::Enum
- Defined in:
- lib/glossarist/designation/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
- #designation ⇒ Object
-
#geographical_area ⇒ Object
Returns the value of attribute geographical_area.
Class Method Summary collapse
Methods included from Utilities::Enum
Methods inherited from Model
#initialize, new, #set_attribute
Constructor Details
This class inherits a constructor from Glossarist::Model
Instance Attribute Details
#designation ⇒ Object
Note:
This is not entirely aligned with agreed schema and may be changed.
10 11 12 |
# File 'lib/glossarist/designation/base.rb', line 10 def designation @designation end |
#geographical_area ⇒ Object
Returns the value of attribute geographical_area.
12 13 14 |
# File 'lib/glossarist/designation/base.rb', line 12 def geographical_area @geographical_area end |
Class Method Details
.from_h(hash) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/glossarist/designation/base.rb', line 15 def self.from_h(hash) type = hash["type"] if type.nil? || /\w/ !~ type raise ArgumentError, "designation type is missing" end designation_subclass = SERIALIZED_TYPES[type] if self == Base # called on Base class, delegate it to proper subclass SERIALIZED_TYPES[type].from_h(hash) else # called on subclass, instantiate object unless SERIALIZED_TYPES[self] == type raise ArgumentError, "unexpected designation type: #{type}" end super(hash.reject { |k, _| k == "type" }) end end |