Sha256: 8b8abc44be2c4e06a4d06fd909f8d9fa76e59d0801bf8d72072de204c775c8b2

Contents?: true

Size: 1.29 KB

Versions: 13

Compression:

Stored size: 1.29 KB

Contents

module Stripe
  module Products
    include ConfigurationBuilder

    configuration_for :product do
      attr_accessor :name,
                    :type,
                    :active,
                    :attributes,
                    :description,
                    :caption,
                    :metadata,
                    :shippable,
                    :url,
                    :statement_descriptor

      validates_presence_of :name, :type

      validates :statement_descriptor, length: { maximum: 22 }

      validates :active, :shippable, inclusion: { in: [true, false] }, allow_nil: true
      validates :type, inclusion: { in: %w(service good) }
      validates :caption, :description, :shippable, :url, absence: true, unless: :good?
      validates :statement_descriptor, absence: true, unless: :service?

      private
      def good?
        type == 'good'
      end

      def service?
        type == 'service'
      end

      def create_options
        {
          name: name,
          type: type,
          active: active,
          attributes: attributes,
          description: description,
          caption: caption,
          metadata: metadata,
          shippable: shippable,
          url: url,
          statement_descriptor: statement_descriptor
        }
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
stripe-rails-1.9.1 lib/stripe/products.rb
stripe-rails-1.9.0 lib/stripe/products.rb
stripe-rails-1.8.2 lib/stripe/products.rb
stripe-rails-1.8.1 lib/stripe/products.rb
stripe-rails-1.8.0 lib/stripe/products.rb
stripe-rails-1.7.2 lib/stripe/products.rb
stripe-rails-1.7.1 lib/stripe/products.rb
stripe-rails-1.7.0 lib/stripe/products.rb
stripe-rails-1.6.1 lib/stripe/products.rb
stripe-rails-1.6.0 lib/stripe/products.rb
stripe-rails-1.5.5 lib/stripe/products.rb
stripe-rails-1.5.4 lib/stripe/products.rb
stripe-rails-1.5.3 lib/stripe/products.rb