Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Misc] Lazy loading #543

Merged
merged 2 commits into from
May 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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