Module: SimpleForum::Configuration
- Defined in:
- lib/simple_forum/configuration.rb
Constant Summary collapse
- @@implementations =
{}
- @@requirements =
[]
Class Method Summary collapse
- .implement(requirement, &blk) ⇒ Object
- .invoke(method, *args) ⇒ Object
- .method_missing(symbol, *args, &block) ⇒ Object
- .requires(*args) ⇒ Object
Class Method Details
.implement(requirement, &blk) ⇒ Object
16 17 18 19 20 |
# File 'lib/simple_forum/configuration.rb', line 16 def self.implement(requirement, &blk) raise ArgumentError, 'You must define an implementation with a symbol!' unless requirement.is_a?(Symbol) @@implementations.merge!({requirement => blk}) @@implementations[requirement] end |
.invoke(method, *args) ⇒ Object
22 23 24 25 26 |
# File 'lib/simple_forum/configuration.rb', line 22 def self.invoke(method, *args) raise ArgumentError, '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] end |
.method_missing(symbol, *args, &block) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/simple_forum/configuration.rb', line 29 def method_missing(symbol, *args, &block) self.class_eval <<-METHOD, __FILE__, __LINE__ + 1 def self.#{symbol}(&block) # def self.authenticated_user(&block) SimpleForum::Configuration.implement(:#{symbol}, &block) # implement(:authenticated_user, &block) end # end METHOD send(symbol, &block) end |
.requires(*args) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/simple_forum/configuration.rb', line 9 def self.requires(*args) args.each do |required_api| raise ArgumentError, 'You must define a requirement with a symbol!' unless required_api.is_a?(Symbol) @@requirements.push required_api end end |