Module: EffectiveMembershipsCard

Extended by:
ActiveSupport::Concern
Included in:
Effective::MembershipCard
Defined in:
app/models/concerns/effective_memberships_card.rb

Overview

EffectiveMembershipsCard Mark your card model with include EffectiveMembershipsCard to get all the includes

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#content_typeObject



25
26
27
# File 'app/models/concerns/effective_memberships_card.rb', line 25

def content_type
  'application/pdf'
end

#filenameObject



29
30
31
# File 'app/models/concerns/effective_memberships_card.rb', line 29

def filename
  "#{self.class.name.split('::').first.downcase}-membership-card-#{Time.zone.now.strftime('%F')}.pdf"
end

#ownerObject

Instance Methods



21
22
23
# File 'app/models/concerns/effective_memberships_card.rb', line 21

def owner
  membership&.owner
end

#pdfObject



42
43
44
# File 'app/models/concerns/effective_memberships_card.rb', line 42

def pdf
  @pdf ||= build_pdf()
end

#to_pdfObject



33
34
35
36
37
38
39
40
# File 'app/models/concerns/effective_memberships_card.rb', line 33

def to_pdf
  raise('is invalid') unless valid?

  return pdf.render() if pdf.respond_to?(:render) # Prawn
  return pdf.to_pdf() if pdf.respond_to?(:to_pdf) # CombinePdf

  pdf
end