Sha256: 3d40d3925ad65e7ba36916c40383c1b61807e368382416eb984e62970fba6104

Contents?: true

Size: 697 Bytes

Versions: 15

Compression:

Stored size: 697 Bytes

Contents

class Membership
  
  include Locomotive::Mongoid::Document
  
  ## fields ##
  field :admin, :type => Boolean, :default => false
  
  ## associations ##
  belongs_to_related :account
  embedded_in :site, :inverse_of => :memberships
  
  ## validations ##
  validates_presence_of :account
  
  ## methods ##
  
  def email; @email; end
  
  def email=(email)
    @email = email
    self.account = Account.where(:email => email).first
  end
  
  def action_to_take
    if @email.blank?
      :error
    elsif self.account.nil?
      :create_account
    elsif self.site.memberships.find_all { |m| m.account_id == self.account_id }.size > 1
      :nothing
    else
      :save_it
    end
  end
  
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
locomotive_cms-0.0.2.9 app/models/membership.rb
locomotive_cms-0.0.2.8 app/models/membership.rb
locomotive_cms-0.0.2.7 app/models/membership.rb
locomotive_cms-0.0.2.6 app/models/membership.rb
locomotive_cms-0.0.2.5 app/models/membership.rb
locomotive_cms-0.0.2.4 app/models/membership.rb
locomotive_cms-0.0.2.3 app/models/membership.rb
locomotive_cms-0.0.2.2 app/models/membership.rb
locomotive_cms-0.0.2.1 app/models/membership.rb
locomotive_cms-0.0.2 app/models/membership.rb
locomotive_cms-0.0.1.4 app/models/membership.rb
locomotive_cms-0.0.1.3 app/models/membership.rb
locomotive_cms-0.0.1.2 app/models/membership.rb
locomotive_cms-0.0.1.1 app/models/membership.rb
locomotive_cms-0.0.1 app/models/membership.rb