Class: SponsoredDonationKit

Inherits:
Kit
  • Object
show all
Defined in:
app/models/kits/sponsored_donation_kit.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Kit

#abilities, #activatable?, activate, activation_requirements, acts_as_kit, #admin_approvable?, admin_approval_requirements, admin_approve, #alternatives, #approvable?, approval_requirements, approve, #has_alternatives?, mailchimp, pad_with_new_kits, #requirements_met?, subklasses, visible, when_active

Methods included from Ext::Integrations::Kit

#record_activation, #record_approval

Class Method Details

.setup_state_machineObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/models/kits/sponsored_donation_kit.rb', line 49

def self.setup_state_machine
  state_machine do
    state :fresh
    state :pending, :enter => :on_pending
    state :activated, :enter => :on_activation
    state :cancelled

    event :activate do
      transitions :from => [:fresh, :pending], :to => :activated, :guard => :activatable?
    end

    event :activate_without_pending do
      transitions :from => [:fresh, :pending, :cancelled], :to => :activated
    end
  end
end

Instance Method Details

#connected?Boolean

Returns:

  • (Boolean)


33
34
35
36
# File 'app/models/kits/sponsored_donation_kit.rb', line 33

def connected?
  errors.add(:requirements, "You need to connect to your Fractured Atlas Membership to active this kit.") unless organization.connected?
  organization.connected?
end

#exclusive?Boolean

Returns:

  • (Boolean)


38
39
40
41
42
# File 'app/models/kits/sponsored_donation_kit.rb', line 38

def exclusive?
  exclusive = !organization.kits.where(:type => alternatives.collect(&:to_s)).any?
  errors.add(:requirements, "You have already activated a mutually exclusive kit.") unless exclusive
  exclusive
end

#friendly_nameObject



25
26
27
# File 'app/models/kits/sponsored_donation_kit.rb', line 25

def friendly_name
  "Sponsored Donations"
end

#has_active_fiscally_sponsored_projectObject



21
22
23
# File 'app/models/kits/sponsored_donation_kit.rb', line 21

def has_active_fiscally_sponsored_project
  organization.has_active_fiscally_sponsored_project?
end

#has_website?Boolean

Returns:

  • (Boolean)


44
45
46
47
# File 'app/models/kits/sponsored_donation_kit.rb', line 44

def has_website?
  errors.add(:requirements, "You need to specify a website for your organization.") unless !organization.website.blank?
  !organization.website.blank?
end

#pitchObject



29
30
31
# File 'app/models/kits/sponsored_donation_kit.rb', line 29

def pitch
  "Contact [email protected] to learn about Fiscal Sponsorship through Fractured Atlas."
end