Class: Protobuf::Mongoid::Transformer
- Inherits:
-
Object
- Object
- Protobuf::Mongoid::Transformer
- Defined in:
- lib/protobuf/mongoid/transformer.rb
Overview
Transformer class
Instance Attribute Summary collapse
-
#callable ⇒ Object
Returns the value of attribute callable.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #call(proto) ⇒ Object
-
#initialize(callable, options = {}) ⇒ Transformer
constructor
A new instance of Transformer.
- #nullify?(proto) ⇒ Boolean
Constructor Details
#initialize(callable, options = {}) ⇒ Transformer
Returns a new instance of Transformer.
9 10 11 12 |
# File 'lib/protobuf/mongoid/transformer.rb', line 9 def initialize(callable, = {}) @callable = callable = end |
Instance Attribute Details
#callable ⇒ Object
Returns the value of attribute callable.
7 8 9 |
# File 'lib/protobuf/mongoid/transformer.rb', line 7 def callable @callable end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/protobuf/mongoid/transformer.rb', line 7 def end |
Instance Method Details
#call(proto) ⇒ Object
14 15 16 17 18 |
# File 'lib/protobuf/mongoid/transformer.rb', line 14 def call(proto) return unless proto callable.call(proto) end |
#nullify?(proto) ⇒ Boolean
20 21 22 23 24 25 26 |
# File 'lib/protobuf/mongoid/transformer.rb', line 20 def nullify?(proto) return false unless [:nullify_on] return false unless proto.field?(:nullify) && proto.nullify.is_a?(Array) return false if proto.nullify.empty? proto.nullify.include?([:nullify_on].to_s) end |