class Module
Public Instance Methods
bool_accessor(*args)
click to toggle source
# File lib/sup/util.rb, line 169 def bool_accessor *args bool_reader(*args) bool_writer(*args) end
bool_reader(*args)
click to toggle source
# File lib/sup/util.rb, line 165 def bool_reader *args args.each { |sym| class_eval %{ def #{sym}?; @#{sym}; end } } end
bool_writer(*args;)
click to toggle source
# File lib/sup/util.rb, line 168 def bool_writer *args; attr_writer(*args); end
defer_all_other_method_calls_to(obj)
click to toggle source
# File lib/sup/util.rb, line 174 def defer_all_other_method_calls_to obj class_eval %{ def method_missing meth, *a, &b; @#{obj}.send meth, *a, &b; end def respond_to?(m, include_private = false) @#{obj}.respond_to?(m, include_private) end } end
yaml_properties(*props)
click to toggle source
# File lib/sup.rb, line 29 def yaml_properties *props props = props.map { |p| p.to_s } path = name.gsub(/::/, "/") yaml_tag "!#{Redwood::YAML_DOMAIN},#{Redwood::YAML_DATE}/#{path}" define_method :init_with do |coder| initialize(*coder.map.values_at(*props)) end define_method :encode_with do |coder| coder.map = props.inject({}) do |hash, key| hash[key] = instance_variable_get("@#{key}") hash end end # Legacy Psych.load_tags["!#{Redwood::LEGACY_YAML_DOMAIN},#{Redwood::YAML_DATE}/#{path}"] = self end