Class: ActiveData::Config
- Inherits:
-
Object
- Object
- ActiveData::Config
- Includes:
- Singleton
- Defined in:
- lib/active_data/config.rb
Instance Attribute Summary collapse
-
#_normalizers ⇒ Object
Returns the value of attribute _normalizers.
-
#_typecasters ⇒ Object
Returns the value of attribute _typecasters.
-
#base_class ⇒ Object
Returns the value of attribute base_class.
-
#base_concern ⇒ Object
Returns the value of attribute base_concern.
-
#i18n_scope ⇒ Object
Returns the value of attribute i18n_scope.
-
#include_root_in_json ⇒ Object
Returns the value of attribute include_root_in_json.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#primary_attribute ⇒ Object
Returns the value of attribute primary_attribute.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #normalizer(name, &block) ⇒ Object
- #typecaster(*classes, &block) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
12 13 14 15 16 17 18 19 |
# File 'lib/active_data/config.rb', line 12 def initialize @include_root_in_json = false @i18n_scope = :active_data @logger = Logger.new(STDERR) @primary_attribute = :id @_normalizers = {} @_typecasters = {} end |
Instance Attribute Details
#_normalizers ⇒ Object
Returns the value of attribute _normalizers.
5 6 7 |
# File 'lib/active_data/config.rb', line 5 def _normalizers @_normalizers end |
#_typecasters ⇒ Object
Returns the value of attribute _typecasters.
5 6 7 |
# File 'lib/active_data/config.rb', line 5 def _typecasters @_typecasters end |
#base_class ⇒ Object
Returns the value of attribute base_class.
5 6 7 |
# File 'lib/active_data/config.rb', line 5 def base_class @base_class end |
#base_concern ⇒ Object
Returns the value of attribute base_concern.
5 6 7 |
# File 'lib/active_data/config.rb', line 5 def base_concern @base_concern end |
#i18n_scope ⇒ Object
Returns the value of attribute i18n_scope.
5 6 7 |
# File 'lib/active_data/config.rb', line 5 def i18n_scope @i18n_scope end |
#include_root_in_json ⇒ Object
Returns the value of attribute include_root_in_json.
5 6 7 |
# File 'lib/active_data/config.rb', line 5 def include_root_in_json @include_root_in_json end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/active_data/config.rb', line 5 def logger @logger end |
#primary_attribute ⇒ Object
Returns the value of attribute primary_attribute.
5 6 7 |
# File 'lib/active_data/config.rb', line 5 def primary_attribute @primary_attribute end |
Class Method Details
.delegated ⇒ Object
8 9 10 |
# File 'lib/active_data/config.rb', line 8 def self.delegated public_instance_methods - superclass.public_instance_methods - Singleton.public_instance_methods end |
Instance Method Details
#normalizer(name, &block) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/active_data/config.rb', line 21 def normalizer(name, &block) if block _normalizers[name.to_sym] = block else _normalizers[name.to_sym] or raise NormalizerMissing, name end end |
#typecaster(*classes, &block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/active_data/config.rb', line 29 def typecaster(*classes, &block) classes = classes.flatten if block _typecasters[classes.first.to_s.camelize] = block else _typecasters[classes.detect do |klass| _typecasters[klass.to_s.camelize] end.to_s.camelize] or raise TypecasterMissing, classes end end |