Class: NotionRubyMapping::Property

Inherits:
Object
  • Object
show all
Defined in:
lib/notion_ruby_mapping/property.rb

Overview

abstract class for property

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, json: nil) ⇒ Property



9
10
11
12
13
# File 'lib/notion_ruby_mapping/property.rb', line 9

def initialize(name, json: nil)
  @name = name
  @will_update = false
  @json = json
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#will_updateObject

Returns the value of attribute will_update.



15
16
17
# File 'lib/notion_ruby_mapping/property.rb', line 15

def will_update
  @will_update
end

Class Method Details

.create_from_json(key, input_json) ⇒ NotionRubyMapping::Property?



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/notion_ruby_mapping/property.rb', line 32

def self.create_from_json(key, input_json)
  keys = input_json.keys
  if keys.include? "number"
    NumberProperty.new key, json: input_json["number"]
  elsif keys.include? "select"
    SelectProperty.new key, json: input_json["select"]
  elsif keys.include? "multi_select"
    MultiSelectProperty.new key, json: input_json["multi_select"]
  elsif keys.include? "date"
    DateProperty.new key, json: input_json["date"]
  else
    nil
  end
end

Instance Method Details

#make_filter_query(key, value) ⇒ NotionRubyMapping::Query



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

def make_filter_query(key, value)
  Query.new(filter: {"property" => @name, type => {key => value}})
end

#typeSymbol



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

def type
  self.class::TYPE
end