Sha256: 2df24c0284dac68579bc930c9f8bd1ad90d7e4446bbb1f2d79f10c775affee72
Contents?: true
Size: 1.12 KB
Versions: 32
Compression:
Stored size: 1.12 KB
Contents
module Recurly class SubscriptionAddOn < Resource # @return [MeasuredUnit] has_one :measured_unit # Singular because the endpoint is /usage not /usages # @return [Usage] has_many :usage define_attribute_methods %w( add_on_code quantity unit_amount_in_cents add_on_type usage_type usage_percentage ) attr_reader :subscription def initialize add_on = nil, subscription = nil super() case add_on when AddOn, SubscriptionAddOn @add_on = add_on if add_on.is_a? AddOn self.add_on_code = add_on.add_on_code self.quantity = add_on.quantity if add_on.unit_amount_in_cents self.unit_amount_in_cents = add_on.unit_amount_in_cents.to_i end when Hash self.attributes = add_on when String, Symbol self.add_on_code = add_on end self.add_on_code = add_on_code.to_s @subscription = subscription end def add_on @add_on ||= subscription.plan.add_ons.find add_on_code end def currency subscription.currency if subscription end end end
Version data entries
32 entries across 32 versions & 1 rubygems