module Icalendar::HasComponents
Public Class Methods
included(base)
click to toggle source
# File lib/icalendar/has_components.rb, line 5 def self.included(base) base.extend ClassMethods base.class_eval do attr_reader :custom_components end end
new(*args)
click to toggle source
Calls superclass method
# File lib/icalendar/has_components.rb, line 12 def initialize(*args) @custom_components = Hash.new { |h, k| h[k] = [] } super end
Public Instance Methods
add_component(c) { |c| ... }
click to toggle source
# File lib/icalendar/has_components.rb, line 17 def add_component(c) c.parent = self yield c if block_given? send("#{c.name.downcase}s") << c c end
method_missing(method, *args) { |custom| ... }
click to toggle source
Calls superclass method
# File lib/icalendar/has_components.rb, line 24 def method_missing(method, *args, &block) method_name = method.to_s if method_name =~ /^add_(x_\w+)$/ component_name = $1 custom = args.first || Component.new(component_name, component_name.upcase) custom_components[component_name] << custom yield custom if block_given? custom else super end end
respond_to_missing?(method_name, include_private = false)
click to toggle source
Calls superclass method
# File lib/icalendar/has_components.rb, line 37 def respond_to_missing?(method_name, include_private = false) method_name.to_s.start_with?('add_x_') || super end