Module: Volt::ModelHelpers

Included in:
ArrayModel, Model
Defined in:
lib/volt/models/model_helpers.rb

Overview

A place for things shared between an ArrayModel and a Model

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



55
56
57
# File 'lib/volt/models/model_helpers.rb', line 55

def self.included(base)
  base.send :extend, ClassMethods
end

Instance Method Details

#deep_unwrap(value) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/volt/models/model_helpers.rb', line 4

def deep_unwrap(value)
  if value.is_a?(Model)
    value.to_h
  elsif value.is_a?(ArrayModel)
    value.to_a
  else
    value
  end
end

#event_added(event, first, first_for_event) ⇒ Object

Pass to the persisotr



15
16
17
# File 'lib/volt/models/model_helpers.rb', line 15

def event_added(event, first, first_for_event)
  @persistor.event_added(event, first, first_for_event) if @persistor
end

#event_removed(event, last, last_for_event) ⇒ Object

Pass to the persistor



20
21
22
# File 'lib/volt/models/model_helpers.rb', line 20

def event_removed(event, last, last_for_event)
  @persistor.event_removed(event, last, last_for_event) if @persistor
end