Class: Filtrum::Settings
- Inherits:
-
Object
- Object
- Filtrum::Settings
- Defined in:
- lib/filtrum/settings.rb
Instance Method Summary collapse
- #configure(&block) ⇒ Object
- #dsl ⇒ Object
-
#initialize(parent = nil) ⇒ Settings
constructor
A new instance of Settings.
- #serialize_type(type, &block) ⇒ Object
- #type_serializers ⇒ Object
Constructor Details
#initialize(parent = nil) ⇒ Settings
Returns a new instance of Settings.
5 6 7 8 |
# File 'lib/filtrum/settings.rb', line 5 def initialize parent = nil @parent = parent @type_serializers = [] end |
Instance Method Details
#configure(&block) ⇒ Object
10 11 12 |
# File 'lib/filtrum/settings.rb', line 10 def configure &block instance_eval &block if block end |
#dsl ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/filtrum/settings.rb', line 22 def dsl m = Module.new do def serialize_type type, &block @settings.serialize_type type, &block end end m.instance_variable_set :@settings, self m end |
#serialize_type(type, &block) ⇒ Object
14 15 16 |
# File 'lib/filtrum/settings.rb', line 14 def serialize_type type, &block @type_serializers << TypeSerializer.new(type, block) end |
#type_serializers ⇒ Object
18 19 20 |
# File 'lib/filtrum/settings.rb', line 18 def type_serializers (@parent ? @parent.type_serializers : []) + @type_serializers end |