Class: Granite::Form::Config
- Inherits:
-
Object
- Object
- Granite::Form::Config
- Includes:
- Singleton
- Defined in:
- lib/granite/form/config.rb
Instance Attribute Summary collapse
-
#_normalizers ⇒ Object
Returns the value of attribute _normalizers.
-
#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.
-
#types ⇒ Object
Returns the value of attribute types.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #normalizer(name, &block) ⇒ Object
- #type_for(klass) ⇒ Object
- #typecaster(class_name, &block) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
13 14 15 16 17 18 19 20 |
# File 'lib/granite/form/config.rb', line 13 def initialize @include_root_in_json = false @i18n_scope = :granite @logger = Logger.new(STDERR) @primary_attribute = :id @_normalizers = {} @types = {} end |
Instance Attribute Details
#_normalizers ⇒ Object
Returns the value of attribute _normalizers.
6 7 8 |
# File 'lib/granite/form/config.rb', line 6 def _normalizers @_normalizers end |
#base_class ⇒ Object
Returns the value of attribute base_class.
6 7 8 |
# File 'lib/granite/form/config.rb', line 6 def base_class @base_class end |
#base_concern ⇒ Object
Returns the value of attribute base_concern.
6 7 8 |
# File 'lib/granite/form/config.rb', line 6 def base_concern @base_concern end |
#i18n_scope ⇒ Object
Returns the value of attribute i18n_scope.
6 7 8 |
# File 'lib/granite/form/config.rb', line 6 def i18n_scope @i18n_scope end |
#include_root_in_json ⇒ Object
Returns the value of attribute include_root_in_json.
6 7 8 |
# File 'lib/granite/form/config.rb', line 6 def include_root_in_json @include_root_in_json end |
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/granite/form/config.rb', line 6 def logger @logger end |
#primary_attribute ⇒ Object
Returns the value of attribute primary_attribute.
6 7 8 |
# File 'lib/granite/form/config.rb', line 6 def primary_attribute @primary_attribute end |
#types ⇒ Object
Returns the value of attribute types.
6 7 8 |
# File 'lib/granite/form/config.rb', line 6 def types @types end |
Class Method Details
.delegated ⇒ Object
9 10 11 |
# File 'lib/granite/form/config.rb', line 9 def self.delegated public_instance_methods - superclass.public_instance_methods - Singleton.public_instance_methods end |
Instance Method Details
#normalizer(name, &block) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/granite/form/config.rb', line 22 def normalizer(name, &block) if block _normalizers[name.to_sym] = block else _normalizers[name.to_sym] or raise NormalizerMissing, name end end |
#type_for(klass) ⇒ Object
36 37 38 39 |
# File 'lib/granite/form/config.rb', line 36 def type_for(klass) key = klass.ancestors.grep(Class).map(&:to_s).find(&types) or raise TypecasterMissing, klass types.fetch(key) end |