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

#attribute_prefixObject



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

def attribute_prefix
  @options[:attribute_prefix] || portal_key
end

#parent_changes_appliedObject



24
25
26
27
28
29
30
31
32
# File 'lib/fmrest/spyke/portal.rb', line 24

def parent_changes_applied
  each do |record|
    record.changes_applied
    # Saving portal data doesn't provide new modIds for the
    # portal records, so we clear them instead. We can still save
    # portal data without a mod_id (it's optional in FM Data API)
    record.mod_id = nil
  end
end

#portal_keyObject



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

def portal_key
  return @options[:portal_key] if @options[:portal_key]
  name
end