<commit_before>module Beef
  module Acts
    module Publishable
      module ClassMethods
        def acts_as_publishable
          send :include, InstanceMethods

          named_scope :published, lambda { { :conditions => ["(published_at IS NOT NULL AND published_at != '') AND published_at <= ? AND (published_to > ? OR published_to IS NULL OR published_to = '')", Time.now, Time.now] } }
          named_scope :draft, :conditions => { :published_at => nil }

          before_save :set_published

          attr_accessor :publish, :hide
        end
      end

      module InstanceMethods

        def published?
          return false if published_at.nil?
          @published ||= published_at < Time.zone.now
        end

      private

        def set_published
          write_attribute :published_at, Time.zone.now if @publish and published_at.nil?
          if @hide    
            write_attribute :published_at, nil 
            write_attribute :published_to, nil 
          end
        end
      end

      def self.included(base)
        base.extend ClassMethods
      end
    end
  end  
end<commit_msg>check for published to datetime as well as published at datetime in published query method<commit_after>module Beef
  module Acts
    module Publishable
      module ClassMethods
        def acts_as_publishable
          send :include, InstanceMethods

          named_scope :published, lambda { { :conditions => ["(published_at IS NOT NULL AND published_at != '') AND published_at <= ? AND (published_to > ? OR published_to IS NULL OR published_to = '')", Time.now, Time.now] } }
          named_scope :draft, :conditions => { :published_at => nil }

          before_save :set_published

          attr_accessor :publish, :hide
        end
      end

      module InstanceMethods

        def published?
          return false if published_at.nil?
          RAILS_DEFAULT_LOGGER.debug "#{published_at} #{published_to}"
          @published ||= (published_at <= Time.zone.now && (published_to.nil? || published_to > Time.zone.now))
        end

      private

        def set_published
          write_attribute :published_at, Time.zone.now if @publish and published_at.nil?
          if @hide
            write_attribute :published_at, nil 
            write_attribute :published_to, nil 
          end
        end
      end

      def self.included(base)
        base.extend ClassMethods
      end
    end
  end  
end
{'fraction_non_alphanumeric': 0.0734208367514356, 'fraction_numerical': 0.0, 'mean_word_length': 2.1840731070496084, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 12, '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': '7575140', 'n_tokens_mistral': 659, 'n_tokens_neox': 641, 'n_words': 195}