Class: ApiMaker::Configuration

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



29
30
31
32
33
34
35
36
37
# File 'lib/api_maker/configuration.rb', line 29

def initialize
  self.ability_class_name = "ApiMaker::Ability"
  self.before_create_event_callbacks = []
  self. = true
  self.devise_sign_out_enabled = true
  self.threadding = true

  @on_error = []
end

Instance Attribute Details

#ability_class_nameObject

Returns the value of attribute ability_class_name.



2
3
4
# File 'lib/api_maker/configuration.rb', line 2

def ability_class_name
  @ability_class_name
end

#before_create_event_callbacksObject

Returns the value of attribute before_create_event_callbacks.



2
3
4
# File 'lib/api_maker/configuration.rb', line 2

def before_create_event_callbacks
  @before_create_event_callbacks
end

#devise_sign_in_enabledObject

Returns the value of attribute devise_sign_in_enabled.



2
3
4
# File 'lib/api_maker/configuration.rb', line 2

def 
  @devise_sign_in_enabled
end

#devise_sign_out_enabledObject

Returns the value of attribute devise_sign_out_enabled.



2
3
4
# File 'lib/api_maker/configuration.rb', line 2

def devise_sign_out_enabled
  @devise_sign_out_enabled
end

#on_thread_callbacksObject

Returns the value of attribute on_thread_callbacks.



2
3
4
# File 'lib/api_maker/configuration.rb', line 2

def on_thread_callbacks
  @on_thread_callbacks
end

#profilingObject

Returns the value of attribute profiling.



2
3
4
# File 'lib/api_maker/configuration.rb', line 2

def profiling
  @profiling
end

#react_native_pathObject

Returns the value of attribute react_native_path.



2
3
4
# File 'lib/api_maker/configuration.rb', line 2

def react_native_path
  @react_native_path
end

#threaddingObject

Returns the value of attribute threadding.



2
3
4
# File 'lib/api_maker/configuration.rb', line 2

def threadding
  @threadding
end

Class Method Details

.configure {|ApiMaker::Configuration.current| ... } ⇒ Object



17
18
19
# File 'lib/api_maker/configuration.rb', line 17

def self.configure
  yield ApiMaker::Configuration.current
end

.currentObject



13
14
15
# File 'lib/api_maker/configuration.rb', line 13

def self.current
  @current ||= ApiMaker::Configuration.new
end

.profile(name_block, &blk) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/api_maker/configuration.rb', line 21

def self.profile(name_block, &blk)
  if ApiMaker::Configuration.current.profiling
    Rack::MiniProfiler.step("AM #{name_block.call}", &blk)
  else
    yield
  end
end

Instance Method Details

#ability_classObject



39
40
41
# File 'lib/api_maker/configuration.rb', line 39

def ability_class
  ability_class_name.constantize
end

#before_create_event(&blk) ⇒ Object



43
44
45
# File 'lib/api_maker/configuration.rb', line 43

def before_create_event(&blk)
  before_create_event_callbacks << blk
end

#on_error(&blk) ⇒ Object



47
48
49
# File 'lib/api_maker/configuration.rb', line 47

def on_error(&blk)
  @on_error << blk
end

#on_thread(&blk) ⇒ Object



51
52
53
54
# File 'lib/api_maker/configuration.rb', line 51

def on_thread(&blk)
  @on_thread_callbacks ||= []
  @on_thread_callbacks << blk
end

#report_error(error) ⇒ Object



56
57
58
59
60
# File 'lib/api_maker/configuration.rb', line 56

def report_error(error)
  @on_error.each do |on_error|
    on_error.call(error)
  end
end