module Icalendar::HasProperties::ClassMethods
Public Instance Methods
default_property_types()
click to toggle source
# File lib/icalendar/has_properties.rb, line 100 def default_property_types @default_property_types ||= Hash.new { |h,k| Icalendar::Values::Text } end
multi_property(prop, klass, new_property)
click to toggle source
# File lib/icalendar/has_properties.rb, line 142 def multi_property(prop, klass, new_property) self.multiple_properties << prop.to_s self.default_property_types[prop.to_s] = klass property_var = "@#{prop}" define_method "#{prop}=" do |value| mapped = map_property_value value, klass, true, new_property if mapped.is_a? Icalendar::Values::Array instance_variable_set property_var, mapped.to_a.compact else instance_variable_set property_var, [mapped].compact end end define_method prop do if instance_variable_defined? property_var instance_variable_get property_var else send "#{prop}=", nil end end define_method "append_#{prop}" do |value| send(prop) << map_property_value(value, klass, true, new_property) end end
multiple_properties()
click to toggle source
# File lib/icalendar/has_properties.rb, line 84 def multiple_properties @multiple_properties ||= [] end
mutex_properties()
click to toggle source
# File lib/icalendar/has_properties.rb, line 96 def mutex_properties @mutex_properties ||= [] end
mutually_exclusive_properties(*properties)
click to toggle source
# File lib/icalendar/has_properties.rb, line 120 def mutually_exclusive_properties(*properties) self.mutex_properties << properties end
optional_property(prop, klass = Icalendar::Values::Text, suggested_single = false, new_property = false)
click to toggle source
# File lib/icalendar/has_properties.rb, line 124 def optional_property(prop, klass = Icalendar::Values::Text, suggested_single = false, new_property = false) self.suggested_single_properties << prop if suggested_single multi_property prop, klass, new_property end
optional_single_property(prop, klass = Icalendar::Values::Text, new_property = false)
click to toggle source
# File lib/icalendar/has_properties.rb, line 116 def optional_single_property(prop, klass = Icalendar::Values::Text, new_property = false) single_property prop, klass, new_property end
properties()
click to toggle source
# File lib/icalendar/has_properties.rb, line 76 def properties single_properties + multiple_properties end
required_multi_property(prop, klass = Icalendar::Values::Text, validator = nil)
click to toggle source
# File lib/icalendar/has_properties.rb, line 110 def required_multi_property(prop, klass = Icalendar::Values::Text, validator = nil) validator ||= ->(component, value) { !value.compact.empty? } self.required_properties[prop] = validator multi_property prop, klass, false end
required_properties()
click to toggle source
# File lib/icalendar/has_properties.rb, line 88 def required_properties @required_properties ||= {} end
required_property(prop, klass = Icalendar::Values::Text, validator = nil)
click to toggle source
# File lib/icalendar/has_properties.rb, line 104 def required_property(prop, klass = Icalendar::Values::Text, validator = nil) validator ||= ->(component, value) { !value.nil? } self.required_properties[prop] = validator single_property prop, klass, false end
single_properties()
click to toggle source
# File lib/icalendar/has_properties.rb, line 80 def single_properties @single_properties ||= [] end
single_property(prop, klass, new_property)
click to toggle source
# File lib/icalendar/has_properties.rb, line 129 def single_property(prop, klass, new_property) self.single_properties << prop.to_s self.default_property_types[prop.to_s] = klass define_method prop do instance_variable_get "@#{prop}" end define_method "#{prop}=" do |value| instance_variable_set "@#{prop}", map_property_value(value, klass, false, new_property) end end
suggested_single_properties()
click to toggle source
# File lib/icalendar/has_properties.rb, line 92 def suggested_single_properties @suggested_single_properties ||= [] end