Class: Brick::Config

Inherits:
Object show all
Includes:
Singleton
Defined in:
lib/brick/config.rb

Overview

Global configuration affecting all threads. Some thread-specific configuration can be found in ‘brick.rb`, others in `controller.rb`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



14
15
16
17
18
19
20
21
# File 'lib/brick/config.rb', line 14

def initialize
  # Variables which affect all threads, whose access is synchronized.
  @mutex = Mutex.new
  @enabled = true

  # Variables which affect all threads, whose access is *not* synchronized.
  @serializer = Brick::Serializers::YAML
end

Instance Attribute Details

#association_reify_error_behaviourObject

Returns the value of attribute association_reify_error_behaviour.



11
12
13
# File 'lib/brick/config.rb', line 11

def association_reify_error_behaviour
  @association_reify_error_behaviour
end

#object_changes_adapterObject

Returns the value of attribute object_changes_adapter.



11
12
13
# File 'lib/brick/config.rb', line 11

def object_changes_adapter
  @object_changes_adapter
end

#root_modelObject

Returns the value of attribute root_model.



11
12
13
# File 'lib/brick/config.rb', line 11

def root_model
  @root_model
end

#serializerObject

Returns the value of attribute serializer.



11
12
13
# File 'lib/brick/config.rb', line 11

def serializer
  @serializer
end

#version_limitObject

Returns the value of attribute version_limit.



11
12
13
# File 'lib/brick/config.rb', line 11

def version_limit
  @version_limit
end

Instance Method Details

#additional_referencesObject

Additional table associations to use (Think of these as virtual foreign keys perhaps)



60
61
62
# File 'lib/brick/config.rb', line 60

def additional_references
  @mutex.synchronize { @additional_references }
end

#additional_references=(references) ⇒ Object



64
65
66
# File 'lib/brick/config.rb', line 64

def additional_references=(references)
  @mutex.synchronize { @additional_references = references }
end

#enable_controllersObject

Indicates whether Brick controllers are on or off. Default: true.



33
34
35
# File 'lib/brick/config.rb', line 33

def enable_controllers
  @mutex.synchronize { !!@enable_controllers }
end

#enable_controllers=(enable) ⇒ Object



37
38
39
# File 'lib/brick/config.rb', line 37

def enable_controllers=(enable)
  @mutex.synchronize { @enable_controllers = enable }
end

#enable_modelsObject

Indicates whether Brick models are on or off. Default: true.



24
25
26
# File 'lib/brick/config.rb', line 24

def enable_models
  @mutex.synchronize { !!@enable_models }
end

#enable_models=(enable) ⇒ Object



28
29
30
# File 'lib/brick/config.rb', line 28

def enable_models=(enable)
  @mutex.synchronize { @enable_models = enable }
end

#enable_routesObject

Indicates whether Brick routes are on or off. Default: true.



51
52
53
# File 'lib/brick/config.rb', line 51

def enable_routes
  @mutex.synchronize { !!@enable_routes }
end

#enable_routes=(enable) ⇒ Object



55
56
57
# File 'lib/brick/config.rb', line 55

def enable_routes=(enable)
  @mutex.synchronize { @enable_routes = enable }
end

#enable_viewsObject

Indicates whether Brick views are on or off. Default: true.



42
43
44
# File 'lib/brick/config.rb', line 42

def enable_views
  @mutex.synchronize { !!@enable_views }
end

#enable_views=(enable) ⇒ Object



46
47
48
# File 'lib/brick/config.rb', line 46

def enable_views=(enable)
  @mutex.synchronize { @enable_views = enable }
end

#exclude_hmsObject

Skip creating a has_many association for these



69
70
71
# File 'lib/brick/config.rb', line 69

def exclude_hms
  @mutex.synchronize { @exclude_hms }
end

#exclude_hms=(skips) ⇒ Object



73
74
75
# File 'lib/brick/config.rb', line 73

def exclude_hms=(skips)
  @mutex.synchronize { @exclude_hms = skips }
end

#exclude_tablesObject



124
125
126
# File 'lib/brick/config.rb', line 124

def exclude_tables
  @mutex.synchronize { @exclude_tables || [] }
end

#exclude_tables=(value) ⇒ Object



128
129
130
# File 'lib/brick/config.rb', line 128

def exclude_tables=(value)
  @mutex.synchronize { @exclude_tables = value }
end

#has_onesObject

Associations to treat as a has_one



92
93
94
# File 'lib/brick/config.rb', line 92

def has_ones
  @mutex.synchronize { @has_ones }
end

#has_ones=(hos) ⇒ Object



96
97
98
# File 'lib/brick/config.rb', line 96

def has_ones=(hos)
  @mutex.synchronize { @has_ones = hos }
end

#metadata_columnsObject



148
149
150
# File 'lib/brick/config.rb', line 148

def 
  @mutex.synchronize { @metadata_columns }
end

#metadata_columns=(columns) ⇒ Object



152
153
154
# File 'lib/brick/config.rb', line 152

def (columns)
  @mutex.synchronize { @metadata_columns = columns }
end

#model_descripsObject



100
101
102
# File 'lib/brick/config.rb', line 100

def model_descrips
  @mutex.synchronize { @model_descrips ||= {} }
end

#model_descrips=(descrips) ⇒ Object



104
105
106
# File 'lib/brick/config.rb', line 104

def model_descrips=(descrips)
  @mutex.synchronize { @model_descrips = descrips }
end

#models_inherit_fromObject



132
133
134
# File 'lib/brick/config.rb', line 132

def models_inherit_from
  @mutex.synchronize { @models_inherit_from }
end

#models_inherit_from=(value) ⇒ Object



136
137
138
# File 'lib/brick/config.rb', line 136

def models_inherit_from=(value)
  @mutex.synchronize { @models_inherit_from = value }
end

#not_nullablesObject



156
157
158
# File 'lib/brick/config.rb', line 156

def not_nullables
  @mutex.synchronize { @not_nullables }
end

#not_nullables=(columns) ⇒ Object



160
161
162
# File 'lib/brick/config.rb', line 160

def not_nullables=(columns)
  @mutex.synchronize { @not_nullables = columns }
end

#skip_database_viewsObject



116
117
118
# File 'lib/brick/config.rb', line 116

def skip_database_views
  @mutex.synchronize { @skip_database_views }
end

#skip_database_views=(disable) ⇒ Object



120
121
122
# File 'lib/brick/config.rb', line 120

def skip_database_views=(disable)
  @mutex.synchronize { @skip_database_views = disable }
end

#skip_index_hmsObject

Skip showing counts for these specific has_many associations when building auto-generated #index views



78
79
80
# File 'lib/brick/config.rb', line 78

def skip_index_hms
  @mutex.synchronize { @skip_index_hms || {} }
end

#skip_index_hms=(skips) ⇒ Object



82
83
84
85
86
87
88
89
# File 'lib/brick/config.rb', line 82

def skip_index_hms=(skips)
  @mutex.synchronize do
    @skip_index_hms ||= skips.each_with_object({}) do |v, s|
                          class_name, assoc_name = v.split('.')
                          (s[class_name] ||= {})[assoc_name.to_sym] = nil
                        end
  end
end

#sti_namespace_prefixesObject



108
109
110
# File 'lib/brick/config.rb', line 108

def sti_namespace_prefixes
  @mutex.synchronize { @sti_namespace_prefixes ||= {} }
end

#sti_namespace_prefixes=(prefixes) ⇒ Object



112
113
114
# File 'lib/brick/config.rb', line 112

def sti_namespace_prefixes=(prefixes)
  @mutex.synchronize { @sti_namespace_prefixes = prefixes }
end

#table_name_prefixesObject



140
141
142
# File 'lib/brick/config.rb', line 140

def table_name_prefixes
  @mutex.synchronize { @table_name_prefixes }
end

#table_name_prefixes=(value) ⇒ Object



144
145
146
# File 'lib/brick/config.rb', line 144

def table_name_prefixes=(value)
  @mutex.synchronize { @table_name_prefixes = value }
end