Merge pull request #3 from finnlabs/feature/rails3_fix_autoload
Moved files around to get autoloaded by rails and removed thepull/6827/head
commit
b82dd87496
@ -1,7 +1,4 @@ |
||||
require_dependency 'reporting_engine/engine_module' |
||||
|
||||
class Report < ActiveRecord::Base |
||||
extend ProactiveAutoloader |
||||
extend Forwardable |
||||
include Enumerable |
||||
include Engine |
@ -1,9 +1,6 @@ |
||||
require "set" |
||||
|
||||
class Report::Filter |
||||
extend ProactiveAutoloader |
||||
autoload :Base, 'reporting_engine/report/filter/base' |
||||
autoload :NoFilter, 'reporting_engine/report/filter/no_filter' |
||||
|
||||
def self.all |
||||
@all ||= Set[] |
@ -1,7 +1,6 @@ |
||||
class Report::Filter |
||||
class Base < Report::Chainable |
||||
include Report::QueryUtils |
||||
|
||||
engine::Operator.load |
||||
|
||||
inherited_attribute :available_operators, |
@ -1,12 +1,7 @@ |
||||
require "set" |
||||
|
||||
class Report::GroupBy |
||||
extend ProactiveAutoloader |
||||
include Report::QueryUtils |
||||
autoload :Base, 'reporting_engine/report/group_by/base' |
||||
autoload :RubyAggregation, 'reporting_engine/report/group_by/ruby_aggregation' |
||||
autoload :SingletonValue, 'reporting_engine/report/group_by/singleton_value.rb' |
||||
autoload :SqlAggregation, 'reporting_engine/report/group_by/sql_aggregation' |
||||
|
||||
def self.all |
||||
Set[engine::GroupBy::SingletonValue] |
@ -1,5 +1,4 @@ |
||||
require 'set' |
||||
require_dependency 'reporting_engine/report' |
||||
|
||||
module Report::InheritedAttribute |
||||
include Report::QueryUtils |
@ -1,9 +1,5 @@ |
||||
module Report::Validation |
||||
extend ProactiveAutoloader |
||||
include Report::QueryUtils |
||||
# autoload :Dates, 'report/validation/dates' |
||||
# autoload :Integers, 'report/validation/integers' |
||||
# autoload :Sql, 'report/validation/sql' |
||||
|
||||
def register_validations(*validation_methods) |
||||
validation_methods.flatten.each do |val_method| |
@ -1,71 +0,0 @@ |
||||
## |
||||
# From Urban Dictionary: |
||||
# proactive (91 up, 9 down) |
||||
# |
||||
# Originally a psychological term indicating an empowered, self-reliant |
||||
# individual, this has evolved through misuse into a neo-antonym of 'reactive', |
||||
# and is used as such to emphasise the preferability of one attitude or course |
||||
# of action over another. It connotes alertness, awareness and preparedness, and |
||||
# seeks to dispel any conceivable impression of incompetence. |
||||
# |
||||
# 'Proactive' is interesting in that it is perhaps the classic example of the |
||||
# unnecessary neologism. It serves as an antonym to 'reactive', yet 'reactive' |
||||
# is itself the antonym of 'active'. |
||||
# |
||||
# Arguably, since 'proactive' is now perhaps more widely used than 'active' for |
||||
# the specific purpose covered by the newer word, 'proactive' must be recognised |
||||
# as a legitimate word. The cult of hatred that has understandably grown up |
||||
# around the word can only help it endure further. |
||||
# |
||||
# One is 'active' as opposed to being 'passive' or 'reactive'. One is |
||||
# 'proactive' as opposed to 'speaking English'. |
||||
module ProactiveAutoloader |
||||
extend self |
||||
|
||||
## |
||||
# Improved Module#autoload: |
||||
# * if path is not given, generate path according to ruby common sense |
||||
# * allow passing multiple constant names as symbols |
||||
# |
||||
# Example: |
||||
# autoload :Foo, :Bar, :Blah |
||||
def autoload(*list) |
||||
return super if list.size == 2 and String === list.last |
||||
list.each do |const| |
||||
super const, "#{name.underscore}/#{const.to_s.underscore}" |
||||
end |
||||
end |
||||
|
||||
## |
||||
# Sets up autoload hooks in +klass+ for all Ruby files in +dir+, following |
||||
# common naming conventions. Subdirectories are *not* scanned. |
||||
def setup_autoloaders(klass, dir) |
||||
Dir.glob File.expand_path('*.rb', dir) do |file| |
||||
klass.autoload File.basename(file, '.rb').camelize, file |
||||
end |
||||
end |
||||
|
||||
## |
||||
# If subclassed, say in foo/bar.rb and there is a directory foo/bar, |
||||
# set up autoload hooks in subclass for all ruby files in foo/bar |
||||
# (see setup_autoloaders). |
||||
def inherited(klass) |
||||
auto_setup_autoloaders(klass) |
||||
super |
||||
end |
||||
|
||||
## |
||||
# If extending a class, say in foo/bar.rb and there is a directory foo/bar, |
||||
# set up autoload hooks in subclass for all ruby files in foo/bar |
||||
# (see setup_autoloaders). |
||||
def self.extended(klass) |
||||
auto_setup_autoloaders(klass) if klass.respond_to? :autoload |
||||
super |
||||
end |
||||
|
||||
private |
||||
|
||||
def auto_setup_autoloaders(klass) |
||||
setup_autoloaders klass, caller[1][/^((?!\.[^\.]+:\d+).)+/] |
||||
end |
||||
end |
@ -1,5 +1,4 @@ |
||||
class Widget::Controls < Widget::Base |
||||
extend ProactiveAutoloader |
||||
|
||||
def cache_key |
||||
"#{super}#{@subject.new_record? ? 1 : 0}" |
@ -1,3 +1,6 @@ |
||||
#make sure to require Widget::Filters::Base first because otherwise |
||||
#ruby might find Base within Widget and Rails will not load it |
||||
require_dependency 'widget/filters/base' |
||||
class Widget::Filters::Date < Widget::Filters::Base |
||||
|
||||
def calendar_for(field_id) |
@ -1,4 +1,6 @@ |
||||
|
||||
#make sure to require Widget::Filters::Base first because otherwise |
||||
#ruby might find Base within Widget and Rails will not load it |
||||
require_dependency 'widget/filters/base' |
||||
class Widget::Filters::Label < Widget::Filters::Base |
||||
def render |
||||
write(content_tag(:td, :width => 150) do |
@ -1,4 +1,6 @@ |
||||
|
||||
#make sure to require Widget::Filters::Base first because otherwise |
||||
#ruby might find Base within Widget and Rails will not load it |
||||
require_dependency 'widget/filters/base' |
||||
class Widget::Filters::MultiChoice < Widget::Filters::Base |
||||
|
||||
def render |
@ -1,3 +1,6 @@ |
||||
#make sure to require Widget::Filters::Base first because otherwise |
||||
#ruby might find Base within Widget and Rails will not load it |
||||
require_dependency 'widget/filters/base' |
||||
class Widget::Filters::MultiValues < Widget::Filters::Base |
||||
|
||||
def render |
@ -1,3 +1,6 @@ |
||||
#make sure to require Widget::Filters::Base first because otherwise |
||||
#ruby might find Base within Widget and Rails will not load it |
||||
require_dependency 'widget/filters/base' |
||||
class Widget::Filters::Operators < Widget::Filters::Base |
||||
def render |
||||
write(content_tag(:td, :width => 100) do |
@ -1,3 +1,6 @@ |
||||
#make sure to require Widget::Filters::Base first because otherwise |
||||
#ruby might find Base within Widget and Rails will not load it |
||||
require_dependency 'widget/filters/base' |
||||
class Widget::Filters::RemoveButton < Widget::Filters::Base |
||||
def render |
||||
write(content_tag(:td, :width => "25px") do |
@ -1,3 +1,6 @@ |
||||
#make sure to require Widget::Filters::Base first because otherwise |
||||
#ruby might find Base within Widget and Rails will not load it |
||||
require_dependency 'widget/filters/base' |
||||
class Widget::Filters::TextBox < Widget::Filters::Base |
||||
def render |
||||
write(content_tag(:td) do |
@ -1,5 +1,4 @@ |
||||
class Widget::GroupBys < Widget::Base |
||||
extend ProactiveAutoloader |
||||
|
||||
def render_options(group_by_ary) |
||||
group_by_ary.sort_by do |group_by| |
@ -1,5 +1,3 @@ |
||||
require_dependency 'reporting_engine/report/inherited_attribute' |
||||
|
||||
class Widget::Table < Widget::Base |
||||
extend Report::InheritedAttribute |
||||
include ReportingHelper |
Loading…
Reference in new issue