Class: RulesIO::MiddlewareConfigurator

Inherits:
Object
  • Object
show all
Defined in:
lib/rulesio/railtie.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMiddlewareConfigurator

Returns a new instance of MiddlewareConfigurator.



64
65
66
# File 'lib/rulesio/railtie.rb', line 64

def initialize
  @configuration = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mid, *args, &block) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/rulesio/railtie.rb', line 72

def method_missing(mid, *args, &block)
  mname = mid.id2name
  if block_given?
    @configuration[mname.to_sym] = *block
  else
    if args.size == 1
      @configuration[mname.to_sym] = args.first
    else
      @configuration[mname.to_sym] = args
    end
  end
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



55
56
57
# File 'lib/rulesio/railtie.rb', line 55

def configuration
  @configuration
end

#rootObject

Returns the value of attribute root.



55
56
57
# File 'lib/rulesio/railtie.rb', line 55

def root
  @root
end

Class Method Details

.apply(root, &block) ⇒ Object



57
58
59
60
61
62
# File 'lib/rulesio/railtie.rb', line 57

def self.apply(root, &block)
  x = new
  x.root = root
  x.configure(&block) if block_given?
  x
end

Instance Method Details

#configure(&block) ⇒ Object



68
69
70
# File 'lib/rulesio/railtie.rb', line 68

def configure(&block)
  instance_eval &block
end