Class: Unit::Types::FullName
- Inherits:
-
Object
- Object
- Unit::Types::FullName
- Defined in:
- lib/unit-ruby/types/full_name.rb
Instance Attribute Summary collapse
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#last ⇒ Object
readonly
Returns the value of attribute last.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json_api ⇒ Object
-
#initialize(first:, last:) ⇒ FullName
constructor
A new instance of FullName.
Constructor Details
#initialize(first:, last:) ⇒ FullName
Returns a new instance of FullName.
6 7 8 9 |
# File 'lib/unit-ruby/types/full_name.rb', line 6 def initialize(first:, last:) @first = first @last = last end |
Instance Attribute Details
#first ⇒ Object (readonly)
Returns the value of attribute first.
4 5 6 |
# File 'lib/unit-ruby/types/full_name.rb', line 4 def first @first end |
#last ⇒ Object (readonly)
Returns the value of attribute last.
4 5 6 |
# File 'lib/unit-ruby/types/full_name.rb', line 4 def last @last end |
Class Method Details
.cast(val) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/unit-ruby/types/full_name.rb', line 11 def self.cast(val) return val if val.is_a? self return nil if val.nil? new(first: val[:first], last: val[:last]) end |
Instance Method Details
#as_json_api ⇒ Object
18 19 20 |
# File 'lib/unit-ruby/types/full_name.rb', line 18 def as_json_api { first: first, last: last } end |