Class: Unit::Types::Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/unit-ruby/types/hash.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items) ⇒ Hash

Returns a new instance of Hash.



8
9
10
# File 'lib/unit-ruby/types/hash.rb', line 8

def initialize(items)
  @items = items || {}
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



6
7
8
# File 'lib/unit-ruby/types/hash.rb', line 6

def items
  @items
end

Class Method Details

.cast(val) ⇒ Object



12
13
14
15
16
# File 'lib/unit-ruby/types/hash.rb', line 12

def self.cast(val)
  return val if val.is_a? self

  new(val)
end

Instance Method Details

#as_json_apiObject



18
19
20
# File 'lib/unit-ruby/types/hash.rb', line 18

def as_json_api
  items
end