Module: RubySerializer::Dsl
- Included in:
- Base
- Defined in:
- lib/ruby_serializer/dsl.rb
Instance Method Summary collapse
- #expose(field, options = {}) ⇒ Object
- #fields ⇒ Object
- #namespace(ns = nil, &block) ⇒ Object
- #serializes(name) ⇒ Object
Instance Method Details
#expose(field, options = {}) ⇒ Object
10 11 12 |
# File 'lib/ruby_serializer/dsl.rb', line 10 def expose(field, = {}) fields << Field.new(field, namespace, ) end |
#fields ⇒ Object
14 15 16 |
# File 'lib/ruby_serializer/dsl.rb', line 14 def fields @fields ||= [] end |
#namespace(ns = nil, &block) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/ruby_serializer/dsl.rb', line 18 def namespace(ns = nil, &block) @namespace ||= [] return @namespace if ns.nil? # this method acts as both getter (this line) and setter (subsequent) @namespace.push(ns) block.call(binding) @namespace.pop end |
#serializes(name) ⇒ Object
4 5 6 7 8 |
# File 'lib/ruby_serializer/dsl.rb', line 4 def serializes(name) define_method(name) do # provide a friendly-name accessor to the underlying resource resource end end |