Class: Representable::ParseStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/representable/parse_strategies.rb

Overview

Parse strategies are just a combination of representable’s options. They save you from memoizing the necessary parameters.

Feel free to contribute your strategy if you think it’s worth sharing!

Defined Under Namespace

Classes: FindOrInstantiate, Proc, Sync

Class Method Summary collapse

Class Method Details

.apply!(options) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/representable/parse_strategies.rb', line 7

def self.apply!(options)
  return unless strategy = options[:parse_strategy]

  strategy = :proc if strategy.is_a?(::Proc)

  parse_strategies[strategy].apply!(name, options)
end

.parse_strategiesObject



15
16
17
18
19
20
21
# File 'lib/representable/parse_strategies.rb', line 15

def self.parse_strategies
  {
    :sync                 => Sync,
    :find_or_instantiate  => FindOrInstantiate,
    :proc                 => Proc
  }
end