Class: NotionRubyMapping::SelectProperty

Inherits:
Property
  • Object
show all
Includes:
EqualsDoesNotEqual, IsEmptyIsNotEmpty
Defined in:
lib/notion_ruby_mapping/select_property.rb

Overview

Select property

Constant Summary collapse

TYPE =
"select"

Instance Attribute Summary

Attributes inherited from Property

#name, #will_update

Instance Method Summary collapse

Methods included from IsEmptyIsNotEmpty

#filter_is_empty, #filter_is_not_empty

Methods included from EqualsDoesNotEqual

#filter_does_not_equal, #filter_equals

Methods inherited from Property

create_from_json, #make_filter_query, #type

Constructor Details

#initialize(name, will_update: false, json: nil, select: nil) ⇒ SelectProperty

Returns a new instance of SelectProperty.

Parameters:

  • name (String)

    Property name

  • json (Hash) (defaults to: nil)
  • select (String) (defaults to: nil)

    String value (optional)



13
14
15
16
# File 'lib/notion_ruby_mapping/select_property.rb', line 13

def initialize(name, will_update: false, json: nil, select: nil)
  super name, will_update: will_update
  @select = select || json && json["name"]
end

Instance Method Details

#property_values_jsonHash

Returns:

  • (Hash)


25
26
27
# File 'lib/notion_ruby_mapping/select_property.rb', line 25

def property_values_json
  {@name => {"type" => "select", "select" => (@select ? {"name" => @select} : @json)}}
end

#select=(select) ⇒ String

Returns settled value.

Parameters:

  • select (String)

Returns:

  • (String)

    settled value



31
32
33
34
# File 'lib/notion_ruby_mapping/select_property.rb', line 31

def select=(select)
  @will_update = true
  @select = select
end

#update_from_json(json) ⇒ Object

Parameters:

  • json (Hash)


19
20
21
22
# File 'lib/notion_ruby_mapping/select_property.rb', line 19

def update_from_json(json)
  @will_update = false
  @select = json["select"]["name"]
end