-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinit.rb
More file actions
68 lines (60 loc) · 2.26 KB
/
init.rb
File metadata and controls
68 lines (60 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# This file was generated by app_extension_generator
# Require libraries we need
require 'csv'
require 'ostruct'
if ENV['RAILS_ENV'] == 'test'
require 'test/spec'
require 'mocha'
end
# 'directory' is defined in rails plugin loading, and since we are eval'd
# instead of required, we get it here. But radiant seems to require or load
# instead of eval, so work with it. Also it can be defined as a function during
# migrations for some reason.
unless defined?(directory) == 'local-variable'
directory = File.dirname(__FILE__)
end
# Load the extension mojo that hacks into the rails base classes.
require File.join(directory, 'ext_lib', 'init.rb')
module ::Office ; end
# Monkey patch into the core classes.
#
# There are two ways to do this, if you are patching into a core class
# like ActiveRecord::Base then you can include a class defined by a file
# in this plugin's lib directory
#
# ActiveRecord::Base.send :include, MyClassInLibDirectory
#
# If you are patching a class in the current application, such as a specific
# model that will get reloaded by the dependencies mechanism (in development
# mode) you will need your extension to be reloaded each time the application
# is reset, so use the hook we provide for you.
#
RbizDependencies.load do
# to add relationships, validations, etc
# SomeModel.send :has_many, :my_model
# to add new methods to instances of a class
# define a module in lib/extensions/some_model_cart_extension
# SomeModel.send :include, SomeModelCartExtension
# SomeModel.new.my_mixed_in_method
# to add new class methods
# define a module in lib/extensions/some_model_cart_class_extension
# SomeModel.send :include, SomeModelCartClassExtension
# SomeModel.my_mixed_in_method
ApplicationController.send :include, CartOfficeAuthorization
end
# copy in assets
if ENV['RAILS_ENV'] == 'development'
require 'fileutils'
['javascripts', 'stylesheets', 'images'].each do |type|
r_path = File.join(RAILS_ROOT, 'public', type, 'cart')
p_path = File.join(File.dirname(__FILE__), 'public', type, 'cart')
unless File.directory?(r_path)
FileUtils.mkdir_p(r_path)
end
Dir["#{p_path}/*"].each do |asset|
unless File.exist?(File.join(r_path, File.basename(asset)))
FileUtils.copy(asset, r_path)
end
end
end
end