module Keytar::ClassMethods
class methods to be extended
Public Instance Methods
build_key(options = {})
click to toggle source
Call Keytar.build_key
or Foo.build_key with options :base => self.to_s.downcase, :name => method_name, :args => args
# File lib/keytar.rb, line 81 def build_key(options = {}) input = options.reverse_merge(key_config) input.delete(:unique) # class methods don't have a unique key Key.build(input) end
define_keys(*args)
click to toggle source
sets up configuration options for individual keys alows us to define the keys without calling method missing
# File lib/keytar.rb, line 61 def define_keys(*args) # coherce args into meaningful things names = []; options = {}; args.each {|arg| arg.is_a?(Hash) ? options = arg : names << arg} names.each do |name| name = name.to_s.gsub(/(^key$|_key$)/, '') Keytar.define_key_class_method_on(self, options.merge(:name => name)) Keytar.define_key_instance_method_on(self, options.merge(:name => name)) end end
Also aliased as: define_key
key_config(options = {})
click to toggle source
a way to define class level configurations for keytar using a hash
# File lib/keytar.rb, line 74 def key_config(options = {}) options[:base] = self @key_config ||= options.reverse_merge(Keytar::DEFAULTS) end