Class: NotionRubyMapping::MultiSelectProperty
- Inherits:
-
MultiProperty
- Object
- Property
- MultiProperty
- NotionRubyMapping::MultiSelectProperty
- Includes:
- ContainsDoesNotContain, IsEmptyIsNotEmpty
- Defined in:
- lib/notion_ruby_mapping/multi_select_property.rb
Overview
MultiSelect property
Constant Summary collapse
- TYPE =
"multi_select"
Instance Attribute Summary
Attributes inherited from Property
Instance Method Summary collapse
-
#initialize(name, will_update: false, json: nil, multi_select: nil) ⇒ MultiSelectProperty
constructor
A new instance of MultiSelectProperty.
-
#multi_select=(multi_select) ⇒ Array?
Settled array.
-
#property_values_json ⇒ Hash
Created json.
- #update_from_json(json) ⇒ Object
Methods included from IsEmptyIsNotEmpty
#filter_is_empty, #filter_is_not_empty
Methods included from ContainsDoesNotContain
#filter_contains, #filter_does_not_contain
Methods inherited from Property
create_from_json, #make_filter_query, #type
Constructor Details
#initialize(name, will_update: false, json: nil, multi_select: nil) ⇒ MultiSelectProperty
Returns a new instance of MultiSelectProperty.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/notion_ruby_mapping/multi_select_property.rb', line 13 def initialize(name, will_update: false, json: nil, multi_select: nil) super name, will_update: will_update @multi_select = if multi_select Array(multi_select) elsif json.is_a? Array json.map { |ms| ms["name"] } else [] end end |
Instance Method Details
#multi_select=(multi_select) ⇒ Array?
Returns settled array.
36 37 38 39 |
# File 'lib/notion_ruby_mapping/multi_select_property.rb', line 36 def multi_select=(multi_select) @will_update = true @multi_select = multi_select ? Array(multi_select) : [] end |
#property_values_json ⇒ Hash
Returns created json.
25 26 27 28 29 30 31 32 |
# File 'lib/notion_ruby_mapping/multi_select_property.rb', line 25 def property_values_json { @name => { "type" => "multi_select", "multi_select" => @multi_select.map { |v| {"name" => v} }, }, } end |
#update_from_json(json) ⇒ Object
42 43 44 45 |
# File 'lib/notion_ruby_mapping/multi_select_property.rb', line 42 def update_from_json(json) @will_update = false @multi_select = json["multi_select"].map { |ms| ms["name"] } end |