<commit_before>module Boom
  module HasVisibility
    def self.included(base)
      base.extend(ClassMethods)
    end
    
    module ClassMethods
      # has_visibility
      def has_visibility
        include Boom::HasVisibility::InstanceMethods
        extend Boom::HasVisibility::SingletonMethods
      end
    end

    module SingletonMethods
      def find_visible
        find(:all, :conditions => {:is_visible => true})
      end
    end
    
    module InstanceMethods
      def toggle_visibility
        self.is_visible = self.is_visible? ? false : true
        self.save
      end

      def hide
        self.is_visible = false
        self.save
      end

      def show
        self.is_visible = true
        self.save
      end
    end
  end
end
<commit_msg>Hooked up find_visible Singleton method to take a conditions hash just like the plain AR find method.<commit_after>module Boom
  module HasVisibility
    def self.included(base)
      base.extend(ClassMethods)
    end
    
    module ClassMethods
      # has_visibility
      def has_visibility
        include Boom::HasVisibility::InstanceMethods
        extend Boom::HasVisibility::SingletonMethods
      end
    end

    module SingletonMethods
      def self.find_visible(which = :all, conds = {})
        (conds[:conditions] ||= {}).merge!({:is_visible => true})
        find(which, conds)
      end
    end
    
    module InstanceMethods
      def toggle_visibility
        self.is_visible = self.is_visible? ? false : true
        self.save
      end

      def hide
        self.is_visible = false
        self.save
      end

      def show
        self.is_visible = true
        self.save
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.06231628453850676, 'fraction_numerical': 0.0, 'mean_word_length': 2.0284697508896796, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '771546', 'n_tokens_mistral': 481, 'n_tokens_neox': 468, 'n_words': 127}