Module: AbstractAuth
- Defined in:
- lib/abstract_auth.rb,
lib/abstract_auth/errors.rb,
lib/abstract_auth/version.rb,
lib/abstract_auth/abstract_auth.rb
Defined Under Namespace
Modules: Errors
Constant Summary collapse
- VERSION =
"0.1.0"
- @@implementations =
{}
- @@requirements =
[]
Class Method Summary collapse
- .implement(requirement, &blk) ⇒ Object
- .invoke(method, *args) ⇒ Object
- .requires(*args) ⇒ Object
-
.setup {|_self| ... } ⇒ Object
Yield AbstractAuth on setup for fancy configuration.
Class Method Details
.implement(requirement, &blk) ⇒ Object
10 11 12 13 |
# File 'lib/abstract_auth/abstract_auth.rb', line 10 def self.implement( requirement , &blk ) raise AbstractAuth::Errors::MalformedImplementationError.new('You must define an implementation with a symbol!') unless requirement.is_a?(Symbol) @@implementations.merge!( { requirement => blk } ) end |
.invoke(method, *args) ⇒ Object
15 16 17 18 19 |
# File 'lib/abstract_auth/abstract_auth.rb', line 15 def self.invoke( method , *args ) raise AbstractAuth::Errors::NonRequiredImplementationCallError.new('The requested implementation was not required!') unless @@requirements.include?(method) raise AbstractAuth::Errors::NotImplementedError.new('The requirement was not implemented!') unless @@implementations.has_key?(method) @@implementations[method].call(args) end |
.requires(*args) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/abstract_auth/abstract_auth.rb', line 3 def self.requires(*args) args.each do |required_api| raise AbstractAuth::Errors::MalformedRequirementError.new('You must define a requirement with a symbol!') unless required_api.is_a?(Symbol) @@requirements.push required_api end end |
.setup {|_self| ... } ⇒ Object
Yield AbstractAuth on setup for fancy configuration
21 22 23 |
# File 'lib/abstract_auth.rb', line 21 def self.setup yield self end |