Class: Representable::ParseStrategy::FindOrInstantiate
- Inherits:
-
Object
- Object
- Representable::ParseStrategy::FindOrInstantiate
- Defined in:
- lib/representable/parse_strategies.rb
Overview
replaces current collection.
Class Method Summary collapse
Class Method Details
.apply!(name, options) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/representable/parse_strategies.rb', line 47 def self.apply!(name, ) [:pass_options] = true [:instance] = lambda { |fragment, *args| args = args.last # TODO: don't pass i as separate block parameter but in Options. object_class = args.binding[:class].evaluate(self, fragment, args) object_class.find_by({id: fragment["id"]}) or object_class.new } end |