Class: FmRest::Spyke::Portal

Inherits:
Spyke::Associations::HasMany
  • Object
show all
Defined in:
lib/fmrest/spyke/portal.rb

Overview

Extend Spyke's HasMany association with custom options

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Portal

Returns a new instance of Portal.



8
9
10
11
12
13
# File 'lib/fmrest/spyke/portal.rb', line 8

def initialize(*args)
  super

  # Portals are always embedded, so no special URI
  @options[:uri] = ""
end

Instance Method Details

#<<(*records) ⇒ Object Also known as: push, concat



29
30
31
32
# File 'lib/fmrest/spyke/portal.rb', line 29

def <<(*records)
  records.flatten.each { |r| add_to_parent(r) }
  self
end

#_remove_marked_for_destructionObject



36
37
38
# File 'lib/fmrest/spyke/portal.rb', line 36

def _remove_marked_for_destruction
  find_some.reject!(&:marked_for_destruction?)
end

#attribute_prefixObject



19
20
21
# File 'lib/fmrest/spyke/portal.rb', line 19

def attribute_prefix
  (@options[:attribute_prefix] || portal_key).to_s
end

#parent_changes_appliedObject

Callback method, not meant to be used directly



25
26
27
# File 'lib/fmrest/spyke/portal.rb', line 25

def parent_changes_applied
  each(&:changes_applied)
end

#portal_keyObject



15
16
17
# File 'lib/fmrest/spyke/portal.rb', line 15

def portal_key
  (@options[:portal_key] || name).to_s
end