Sha256: 780b8225665d22d3a5e4f5d9c73393467bc2b4d3c0d187af5a02cb429a85ab99
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
module FmRest module Spyke # Extend Spyke's HasMany association with custom options # class Portal < ::Spyke::Associations::HasMany def initialize(*args) super # Portals are always embedded, so no special URI @options[:uri] = "" end def portal_key return @options[:portal_key] if @options[:portal_key] name end def attribute_prefix @options[:attribute_prefix] || portal_key end 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 private # 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 def primary_key; end # Make sure the association doesn't try to fetch records through URI def uri; nil; end def embedded_data parent.attributes[portal_key] end def add_to_parent(record) find_some << record record end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fmrest-0.1.0 | lib/fmrest/spyke/portal.rb |