lib/gmail-britta/single_write_accessors.rb
# Defines a boolean-typed filter accessor DSL method. If the
# method gets called in the filter definition block, that causes
# the value to switch to `true`.
# @note There is no way to turn these boolean values back off in
#   Gmail's export XML.
# @param name [Symbol] the name of the accessor method
# @param gmail_name [String] the name of the attribute in the
#   gmail Atom export
Defines a boolean-typed filter accessor DSL method. If the
method gets called in the filter definition block, that causes
the value to switch to `true`.
Defines a boolean - typed filter accessor DSL method . If the method gets called in the filter definition block that causes the value to switch to ` true ` .
def single_write_boolean_accessor(name, gmail_name)
        direct_single_write_accessors[name] = gmail_name
        ivar = ivar_name(name)
        define_method(name) do |*args|
          value = args.length > 0 ? args[0] : true
          if instance_variable_get(ivar)
            raise "Only one use of #{name} is permitted per filter"
          end
          instance_variable_set(ivar, value)
        end
        get(name, ivar)
        output(name, ivar)
      end
def single_write_boolean_accessor ( name , gmail_name ) direct_single_write_accessors [ name ] = gmail_name ivar = ivar_name ( name ) define_method ( name ) do | * args | value = args . length > 0 ? args [ 0 ] : true if instance_variable_get ( ivar ) raise "Only one use of #{name} is permitted per filter" end instance_variable_set ( ivar , value ) end get ( name , ivar ) output ( name , ivar ) end
Defines a boolean-typed filter accessor DSL method.
Defines a boolean - typed filter accessor DSL method .
name
the name of the accessor method
the name of the accessor method
gmail_name
the name of the attribute in the gmail Atom export
the name of the attribute in the gmail Atom export
note
There is no way to turn these boolean values back off in Gmail's export XML.
There is no way to turn these boolean values back off in Gmail ' s export XML .