# File lib/fmrest/spyke/portal.rb, line 46 def primary_key; end
class FmRest::Spyke::Portal
Extend Spyke's HasMany association with custom options
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/fmrest/spyke/portal.rb, line 8 def initialize(*args) super # Portals are always embedded, so no special URI @options[:uri] = "" end
Public Instance Methods
<<(*records)
click to toggle source
# File lib/fmrest/spyke/portal.rb, line 29 def <<(*records) records.flatten.each { |r| add_to_parent(r) } self end
_remove_marked_for_destruction()
click to toggle source
# File lib/fmrest/spyke/portal.rb, line 36 def _remove_marked_for_destruction find_some.reject!(&:marked_for_destruction?) end
attribute_prefix()
click to toggle source
# File lib/fmrest/spyke/portal.rb, line 19 def attribute_prefix (@options[:attribute_prefix] || portal_key).to_s end
parent_changes_applied()
click to toggle source
Callback method, not meant to be used directly
# File lib/fmrest/spyke/portal.rb, line 25 def parent_changes_applied each(&:changes_applied) end
portal_key()
click to toggle source
# File lib/fmrest/spyke/portal.rb, line 15 def portal_key (@options[:portal_key] || name).to_s end
Private Instance Methods
add_to_parent(record)
click to toggle source
Spyke
override
# File lib/fmrest/spyke/portal.rb, line 57 def add_to_parent(record) raise ArgumentError, "Expected an instance of #{klass}, got a #{record.class} instead" unless record.kind_of?(klass) find_some << record record.embedded_in_portal record end
embedded_data()
click to toggle source
# File lib/fmrest/spyke/portal.rb, line 51 def embedded_data parent.attributes[portal_key] end
primary_key()
click to toggle source
Spyke::Associations::HasMany#initialize calls primary_key
to build the default URI, which causes a NameError, so this is here just to prevent that. We don't care what it returns as we override the URI with nil anyway
uri()
click to toggle source
Make sure the association doesn't try to fetch records through URI
# File lib/fmrest/spyke/portal.rb, line 49 def uri; nil; end