Class: NotionRubyMapping::PeopleProperty
- Inherits:
-
MultiProperty
- Object
- Property
- MultiProperty
- NotionRubyMapping::PeopleProperty
- Defined in:
- lib/notion_ruby_mapping/people_property.rb
Overview
PeopleProperty class
Constant Summary collapse
- TYPE =
"people"
Instance Attribute Summary
Attributes inherited from Property
Instance Method Summary collapse
-
#initialize(name, will_update: false, json: nil, people: nil) ⇒ PeopleProperty
constructor
A new instance of PeopleProperty.
-
#people=(people) ⇒ 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, people: nil) ⇒ PeopleProperty
Returns a new instance of PeopleProperty.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/notion_ruby_mapping/people_property.rb', line 11 def initialize(name, will_update: false, json: nil, people: nil) super name, will_update: will_update @people = if people Array(people).map { |uo| UserObject.user_object(uo) } elsif json json.map { |p| UserObject.new json: p } else [] end end |
Instance Method Details
#people=(people) ⇒ Array?
Returns settled array.
40 41 42 43 |
# File 'lib/notion_ruby_mapping/people_property.rb', line 40 def people=(people) @will_update = true @people = people ? Array(people).map { |uo| UserObject.user_object(uo) } : [] end |
#property_values_json ⇒ Hash
Returns created json.
23 24 25 26 27 28 29 30 |
# File 'lib/notion_ruby_mapping/people_property.rb', line 23 def property_values_json { @name => { "type" => "people", "people" => @people.map(&:property_values_json), }, } end |
#update_from_json(json) ⇒ Object
33 34 35 36 |
# File 'lib/notion_ruby_mapping/people_property.rb', line 33 def update_from_json(json) @will_update = false @people = json["people"].map { |pjson| UserObject.new json: pjson } end |