Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request mbleigh#543 from seuros/lazy
Browse files Browse the repository at this point in the history
[Misc] Lazy loading
  • Loading branch information
seuros committed May 23, 2014
2 parents 09714cb + a60a777 commit 6142a40
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 26 deletions.
45 changes: 25 additions & 20 deletions lib/acts-as-taggable-on.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@
require 'digest/sha1'

module ActsAsTaggableOn
extend ActiveSupport::Autoload

autoload :Engine
autoload :Tag
autoload :TagList
autoload :Taggable
autoload :Tagger
autoload :Tagging
autoload :TagsHelper

autoload_under 'taggable' do
autoload :Cache
autoload :Collection
autoload :Core
autoload :Dirty
autoload :Ownership
autoload :Related
end

autoload :Utils
autoload :Compatibility


class DuplicateTagError < StandardError
end

Expand All @@ -16,7 +39,7 @@ def self.setup

def self.method_missing(method_name, *args, &block)
@configuration.respond_to?(method_name) ?
@configuration.send(method_name, *args, &block) : super
@configuration.send(method_name, *args, &block) : super
end

def self.respond_to?(method_name, include_private=false)
Expand All @@ -31,7 +54,7 @@ def self.glue

class Configuration
attr_accessor :delimiter, :force_lowercase, :force_parameterize,
:strict_case_match, :remove_unused_tags
:strict_case_match, :remove_unused_tags

def initialize
@delimiter = ','
Expand All @@ -45,24 +68,6 @@ def initialize
setup
end

require 'acts_as_taggable_on/utils'

require 'acts_as_taggable_on/taggable'
require 'acts_as_taggable_on/acts_as_taggable_on/compatibility'
require 'acts_as_taggable_on/acts_as_taggable_on/core'
require 'acts_as_taggable_on/acts_as_taggable_on/collection'
require 'acts_as_taggable_on/acts_as_taggable_on/cache'
require 'acts_as_taggable_on/acts_as_taggable_on/ownership'
require 'acts_as_taggable_on/acts_as_taggable_on/related'
require 'acts_as_taggable_on/acts_as_taggable_on/dirty'

require 'acts_as_taggable_on/tagger'
require 'acts_as_taggable_on/tag'
require 'acts_as_taggable_on/tag_list'
require 'acts_as_taggable_on/tags_helper'
require 'acts_as_taggable_on/tagging'
require 'acts_as_taggable_on/engine'

ActiveSupport.on_load(:active_record) do
extend ActsAsTaggableOn::Compatibility
extend ActsAsTaggableOn::Taggable
Expand Down
13 changes: 7 additions & 6 deletions lib/acts_as_taggable_on/taggable.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module ActsAsTaggableOn
module Taggable

def taggable?
false
end
Expand Down Expand Up @@ -90,12 +91,12 @@ def self.taggable?

# each of these add context-specific methods and must be
# called on each call of taggable_on
include ActsAsTaggableOn::Taggable::Core
include ActsAsTaggableOn::Taggable::Collection
include ActsAsTaggableOn::Taggable::Cache
include ActsAsTaggableOn::Taggable::Ownership
include ActsAsTaggableOn::Taggable::Related
include ActsAsTaggableOn::Taggable::Dirty
include Core
include Collection
include Cache
include Ownership
include Related
include Dirty
end
end
end

0 comments on commit 6142a40

Please sign in to comment.