<commit_before>module Spree
  class ShippingMethod < ActiveRecord::Base
    DISPLAY =  [:both, :front_end, :back_end]
    belongs_to :zone
    has_many :shipments
    validates :name, :calculator, :zone, :presence => true
    belongs_to :shipping_category

    calculated_adjustments

    def available?(order, display_on=nil)
      display_check = (self.display_on == display_on.to_s || self.display_on.blank?)
      calculator_check = calculator.available?(order)
      display_check && calculator_check
    end

    def available_to_order?(order, display_on=nil)
      availability_check = available?(order,display_on)
      zone_check = zone && zone.include?(order.ship_address)
      category_check = category_match?(order)
      availability_check && zone_check && category_check
    end

    # Indicates whether or not the category rules for this shipping method
    # are satisfied (if applicable)
    def category_match?(order)
      return true if shipping_category.nil?

      if match_all
        order.products.all? { |p| p.shipping_category == shipping_category }<commit_msg>Make name, zone_id, display_on, shipping_category_id, match_none, match_one and match_all available in ShippingMethod<commit_after>module Spree
  class ShippingMethod < ActiveRecord::Base
    DISPLAY =  [:both, :front_end, :back_end]
    belongs_to :zone
    has_many :shipments
    validates :name, :calculator, :zone, :presence => true
    belongs_to :shipping_category

    attr_accessible :name, :zone_id, :display_on, :shipping_category_id, :match_none, :match_one, :match_all

    calculated_adjustments

    def available?(order, display_on=nil)
      display_check = (self.display_on == display_on.to_s || self.display_on.blank?)
      calculator_check = calculator.available?(order)
      display_check && calculator_check
    end

    def available_to_order?(order, display_on=nil)
      availability_check = available?(order,display_on)
      zone_check = zone && zone.include?(order.ship_address)
      category_check = category_match?(order)
      availability_check && zone_check && category_check
    end

    # Indicates whether or not the category rules for this shipping method
    # are satisfied (if applicable)
    def category_match?(order)
      return true if shipping_category.nil?

      if match_all
        order.products.all? { |p| p.shipping_category == shipping_category }
{'fraction_non_alphanumeric': 0.08695652173913043, 'fraction_numerical': 0.0, 'mean_word_length': 4.016771488469602, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5818022', 'n_tokens_mistral': 709, 'n_tokens_neox': 705, 'n_words': 169}