Sha256: 6cb5ea2d8c0b726206cd8d206cd6f7e293476be3eb15d8a7782e450be3017fb7

Contents?: true

Size: 988 Bytes

Versions: 9

Compression:

Stored size: 988 Bytes

Contents

# -*- encoding : utf-8 -*-

card_accessor :email
card_accessor :password
card_accessor :salt
card_accessor :status

require_field :email

def accounted
  left
end

def accounted_id
  left_id
end

def ok_to_read
  own_account? || super
end

# allow account owner to update account field content
def ok_to_update
  (own_account? && !name_changed? && !type_id_changed?) || super
end

def changes_visible? act
  act.actions_affecting(act.card).each do |action|
    return true if action.card.ok? :read
  end
  false
end

def send_account_email email_template
  ecard = Card[email_template]
  unless ecard&.type_id == EmailTemplateID
    raise Card::Error, "invalid email template: #{email_template}"
  end

  ecard.deliver self, to: email
end

def method_missing method, *args
  return super unless args.empty? && (matches = method.match(/^(?<status>.*)\?$/))

  status == matches[:status]
end

def respond_to_missing? method, _include_private=false
  method.match?(/\?$/) ? true : super
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
card-mod-account-0.16.0 set/right/account.rb
card-mod-account-0.15.6 set/right/account.rb
card-mod-account-0.15.5 set/right/account.rb
card-mod-account-0.15.4 set/right/account.rb
card-mod-account-0.15.3 set/right/account.rb
card-mod-account-0.15.2.pre1 set/right/account.rb
card-mod-account-0.15.1.1 set/right/account.rb
card-mod-account-0.15.1 set/right/account.rb
card-mod-account-0.15.0 set/right/account.rb