Module: PadlockAuth::Mixins::BuildWith

Extended by:
ActiveSupport::Concern
Included in:
Config, Token::Strategy
Defined in:
lib/padlock_auth/mixins/build_with.rb

Overview

Provides a quick way to build configuration instances.

Provide ‘PadlockAuth::Utils::AbstractBuilder` sub-class to the `build_with` class method, to define a build method that will take a block to configure the instance.

Examples:

class MyConfig
  include PadlockAuth::Mixins::BuildWith

  class Builder < PadlockAuth::Utils::AbstractBuilder
    def name(value)
      config.instance_variable_set(:@name, value)
    end
  end

  build_with Builder
end

config = MyConfig.build do
  name 'My Name'
end
config.name # => 'My Name'