Class: BlockKit::Types::Set
- Inherits:
-
Array
- Object
- ActiveModel::Type::Value
- Array
- BlockKit::Types::Set
show all
- Defined in:
- lib/block_kit/types/set.rb
Overview
Allows declaring ActiveModel attributes that are Sets of specific types, powered by an internal TypedSet class that enforces type constraints on set members any time the set is modified or any time set operations are performed against other collections.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Array
#initialize, of
Instance Attribute Details
#item_type ⇒ Object
Returns the value of attribute item_type.
12
13
14
|
# File 'lib/block_kit/types/set.rb', line 12
def item_type
@item_type
end
|
Instance Method Details
#cast(value) ⇒ Object
18
19
20
21
22
|
# File 'lib/block_kit/types/set.rb', line 18
def cast(value)
return nil if value.nil?
TypedSet.new(item_type, Array(value))
end
|
#changed_in_place?(raw_old_value, new_value) ⇒ Boolean
30
31
32
|
# File 'lib/block_kit/types/set.rb', line 30
def changed_in_place?(raw_old_value, new_value)
cast(raw_old_value) != cast(new_value)
end
|
#serialize(value) ⇒ Object
24
25
26
27
28
|
# File 'lib/block_kit/types/set.rb', line 24
def serialize(value)
return nil if value.nil?
cast(value)
end
|
#type ⇒ Object
14
15
16
|
# File 'lib/block_kit/types/set.rb', line 14
def type
:set
end
|