class Fog::Associations::OneIdentity

Fog Single Association

This class handles single association between the models. It expects the provider to return only the id of the association. The association model will be loaded based on the id initialized.

Public Instance Methods

create_getter() click to toggle source
# File lib/fog/core/associations/one_identity.rb, line 17
      def create_getter
        model.class_eval "          def #{name}
            return nil if associations[:#{name}].nil?
            service.send(self.class.associations[:#{name}]).get(associations[:#{name}])
          end
", __FILE__, __LINE__
      end
create_setter() click to toggle source
# File lib/fog/core/associations/one_identity.rb, line 9
      def create_setter
        model.class_eval "          def #{name}=(new_#{name})
            associations[:#{name}] = new_#{name}.respond_to?(:identity) ? new_#{name}.identity : new_#{name}
          end
", __FILE__, __LINE__
      end