Module: Ghaki::Account::SynOpts

Included in:
DB_Connect, DB_Driver, DB_Name, DB_Port, DomainAddress, EMailAddress, Hostname, Password, UserDomain, Username
Defined in:
lib/ghaki/account/syn_opts.rb

Instance Method Summary collapse

Instance Method Details

#attr_syn_opts(token, *syn_list) ⇒ Object




7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ghaki/account/syn_opts.rb', line 7

def attr_syn_opts token, *syn_list
  klass = self.to_s.split('::').last
  konst = klass.upcase
  module_eval <<-"END"
  
    #{konst}_LIST = syn_list

    def #{klass}.parse_opts opts
      return opts[ :#{token} ] if opts.has_key?( :#{token} )
      #{konst}_LIST.each do |name|
        return opts[name] if opts.has_key?(name)
      end
      return opts[:account].#{token} if opts.has_key?(:account)
      nil
    end

    def #{klass}.purge_opts opts
       opts.delete( :#{token} )
      #{konst}_LIST.each do |name|
        opts.delete(name)
      end
      opts
    end

    def opt_#{token} opts
      val = #{klass}.parse_opts( opts )
      @#{token} = val unless val.nil?
    end

  END
end