Class: NotionRubyMapping::RelationProperty
- Inherits:
-
MultiProperty
- Object
- Property
- MultiProperty
- NotionRubyMapping::RelationProperty
- Defined in:
- lib/notion_ruby_mapping/relation_property.rb
Overview
MultiSelect property
Constant Summary collapse
- TYPE =
"relation"
Instance Attribute Summary
Attributes inherited from Property
Instance Method Summary collapse
-
#initialize(name, will_update: false, json: nil, relation: nil) ⇒ RelationProperty
constructor
A new instance of RelationProperty.
-
#property_values_json ⇒ Hash
Created json.
-
#relation=(relation) ⇒ Array<String>
Settled relation Array.
- #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, relation: nil) ⇒ RelationProperty
Returns a new instance of RelationProperty.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/notion_ruby_mapping/relation_property.rb', line 11 def initialize(name, will_update: false, json: nil, relation: nil) super name, will_update: will_update @relation = if relation Array(relation) elsif json json.map { |r| r["id"] } else [] end end |
Instance Method Details
#property_values_json ⇒ Hash
Returns created json.
36 37 38 39 40 41 42 43 |
# File 'lib/notion_ruby_mapping/relation_property.rb', line 36 def property_values_json { @name => { "type" => "relation", "relation" => @relation.map { |rid| {"id" => rid} }, }, } end |
#relation=(relation) ⇒ Array<String>
Returns settled relation Array.
24 25 26 27 |
# File 'lib/notion_ruby_mapping/relation_property.rb', line 24 def relation=(relation) @will_update = true @relation = Array(relation) end |
#update_from_json(json) ⇒ Object
30 31 32 33 |
# File 'lib/notion_ruby_mapping/relation_property.rb', line 30 def update_from_json(json) @will_update = false @relation = json["relation"].map { |r| r["id"] } end |