Module: Credentials::ClassMethods

Defined in:
lib/credentials/class_methods.rb

Instance Method Summary collapse

Instance Method Details

#credentials(options = {}) {|rulebook| ... } ⇒ Object

Defines the set of credentials common to members of a class.

Yields:

  • (rulebook)


4
5
6
7
8
9
10
11
12
13
14
# File 'lib/credentials/class_methods.rb', line 4

def credentials(options = {}, &block)
  unless included_modules.include? Actor
    class_inheritable_reader :rulebook
    class_inheritable_reader :credential_options
    include Actor
  end
  write_inheritable_attribute :credential_options, merge_credential_options(read_inheritable_attribute(:credential_options), options)
  old_rulebook = read_inheritable_attribute(:rulebook)
  write_inheritable_attribute :rulebook, Rulebook.new(self, old_rulebook ? old_rulebook.rules : [])
  yield rulebook if block_given?
end