Class: GenericModel
- Defined in:
- lib/gorillib/factories.rb
Overview
Manufactures objects from their raw attributes hash
The hash must have a value for :_type
, used to retrieve the actual factory
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.receive(obj) ⇒ Object
212 |
# File 'lib/gorillib/factories.rb', line 212 def self.receive(obj) allocate.receive(obj) end |
Instance Method Details
#blankish?(obj) ⇒ Boolean
204 |
# File 'lib/gorillib/factories.rb', line 204 def blankish?(obj) obj.nil? ; end |
#native?(obj) ⇒ Boolean
205 |
# File 'lib/gorillib/factories.rb', line 205 def native?(obj) false ; end |
#receive(attrs, &block) ⇒ Object
206 207 208 209 210 211 |
# File 'lib/gorillib/factories.rb', line 206 def receive(attrs, &block) Gorillib::Model::Validate.hashlike!(attrs){ "attributes for typed object" } klass = Gorillib::Factory(attrs.fetch(:_type){ attrs.fetch("_type") }) # klass.new(attrs, &block) end |