Class: NotionRubyMapping::CheckboxProperty

Inherits:
Property
  • Object
show all
Includes:
EqualsDoesNotEqual
Defined in:
lib/notion_ruby_mapping/properties/checkbox_property.rb

Overview

Checkbox property

Constant Summary collapse

TYPE =
"checkbox"

Instance Attribute Summary

Attributes inherited from Property

#name, #property_cache, #property_id, #will_update

Instance Method Summary collapse

Methods included from EqualsDoesNotEqual

#filter_does_not_equal, #filter_equals

Methods inherited from Property

#assert_database_property, #assert_page_property, #clear_will_update, #contents?, create_from_json, #database?, #make_filter_query, #new_name=, #page?, #property_schema_json, #remove, #retrieve_page_property, #type, #update_from_json, #update_property_schema_json

Constructor Details

#initialize(name, will_update: false, base_type: "page", property_id: nil, property_cache: nil, json: nil) ⇒ CheckboxProperty

Returns a new instance of CheckboxProperty.

Parameters:

  • name (String, Symbol)

    Property name

  • json (Boolean, Hash) (defaults to: nil)


36
37
38
39
40
41
42
43
44
# File 'lib/notion_ruby_mapping/properties/checkbox_property.rb', line 36

def initialize(name, will_update: false, base_type: "page", property_id: nil, property_cache: nil, json: nil)
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
              property_cache: property_cache
  @json = if database?
            json || {}
          else
            json || false
          end
end

Instance Method Details

#checkboxBoolean, ...



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

def checkbox
  @json
end

#checkbox=(flag) ⇒ TrueClass, FalseClass

Returns settled value.

Parameters:

  • flag (Boolean)

Returns:

  • (TrueClass, FalseClass)

    settled value

See Also:



24
25
26
27
28
# File 'lib/notion_ruby_mapping/properties/checkbox_property.rb', line 24

def checkbox=(flag)
  assert_page_property __method__
  @will_update = true
  @json = flag
end

#property_values_jsonHash

Returns:

  • (Hash)


49
50
51
52
# File 'lib/notion_ruby_mapping/properties/checkbox_property.rb', line 49

def property_values_json
  assert_page_property __method__
  {@name => {"checkbox" => @json, "type" => "checkbox"}}
end