Sha256: 2b360f6480f914c87fb25e8599a95f6c07cea037fa434feb3fd6791281f14387

Contents?: true

Size: 1.36 KB

Versions: 17

Compression:

Stored size: 1.36 KB

Contents

module Stripe
  module Products
    include ConfigurationBuilder

    configuration_for :product do
      attr_accessor :name,
                    :type,
                    :active,
                    :attributes,
                    :description,
                    :caption,
                    :metadata,
                    :shippable,
                    :unit_label,
                    :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,
          unit_label: unit_label,
          url: url,
          statement_descriptor: statement_descriptor
        }
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
stripe-rails-2.6.0 lib/stripe/products.rb
stripe-rails-2.5.0 lib/stripe/products.rb
stripe-rails-2.4.0 lib/stripe/products.rb
stripe-rails-2.3.5 lib/stripe/products.rb
stripe-rails-2.3.4 lib/stripe/products.rb
stripe-rails-2.3.3 lib/stripe/products.rb
stripe-rails-2.3.2 lib/stripe/products.rb
stripe-rails-2.3.1 lib/stripe/products.rb
stripe-rails-2.3.0 lib/stripe/products.rb
stripe-rails-2.2.1 lib/stripe/products.rb
stripe-rails-2.2.0 lib/stripe/products.rb
stripe-rails-2.1.0 lib/stripe/products.rb
stripe-rails-2.0.0 lib/stripe/products.rb
stripe-rails-1.10.2 lib/stripe/products.rb
stripe-rails-2.0.0.pre lib/stripe/products.rb
stripe-rails-1.10.1 lib/stripe/products.rb
stripe-rails-1.10.0 lib/stripe/products.rb