Class: Aker::Confident::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/aker/confident/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options_hash = {}) ⇒ Configuration

Returns a new instance of Configuration.



9
10
11
12
13
14
15
16
17
# File 'lib/aker/confident/configuration.rb', line 9

def initialize(options_hash={})
  @pass_through_hooks = []
  conf_model(options_hash[:conf_model])
  conf_file(options_hash[:conf_file])
  set_url options_hash[:root_url]
  if options_hash[:conf_host_hook]
    conf_host_hook options_hash[:conf_host_hook]
  end
end

Instance Attribute Details

#agreementObject

Returns the value of attribute agreement.



7
8
9
# File 'lib/aker/confident/configuration.rb', line 7

def agreement
  @agreement
end

#host_hookObject

Returns the value of attribute host_hook.



7
8
9
# File 'lib/aker/confident/configuration.rb', line 7

def host_hook
  @host_hook
end

#pass_through_hooksObject (readonly)

Returns the value of attribute pass_through_hooks.



8
9
10
# File 'lib/aker/confident/configuration.rb', line 8

def pass_through_hooks
  @pass_through_hooks
end

#root_urlObject

Returns the value of attribute root_url.



7
8
9
# File 'lib/aker/confident/configuration.rb', line 7

def root_url
  @root_url
end

Instance Method Details

#conf_file(file_name) ⇒ Object



36
37
38
# File 'lib/aker/confident/configuration.rb', line 36

def conf_file(file_name)
  @agreement_file = file_name
end

#conf_host_hook(callable) ⇒ Object



40
41
42
# File 'lib/aker/confident/configuration.rb', line 40

def conf_host_hook(callable)
  @pass_through_hooks << callable
end

#conf_model(model_name) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/aker/confident/configuration.rb', line 24

def conf_model(model_name)
  if model_name == :default
    @model = Confident::DefaultSignature
  else
    @model = model_name
  end
end

#define(&block) ⇒ Object



19
20
21
22
# File 'lib/aker/confident/configuration.rb', line 19

def define &block
  instance_eval &block
  self
end

#modelObject



55
56
57
58
59
60
61
# File 'lib/aker/confident/configuration.rb', line 55

def model
  if @model.is_a? String
    @model.constantize
  else
    @model
  end
end

#set_url(url) ⇒ Object



32
33
34
# File 'lib/aker/confident/configuration.rb', line 32

def set_url(url)
  @root_url = url
end

#verify!Object



44
45
46
47
48
49
# File 'lib/aker/confident/configuration.rb', line 44

def verify!
  validate_agreement_file!
  load_agreement_file
  validate_hook!
  validate_model!
end