lib/acts-as-assetable.rb in acts-as-assetable-0.0.1.5 vs lib/acts-as-assetable.rb in acts-as-assetable-0.0.2.0
- old
+ new
@@ -1,40 +1,19 @@
-module ActsAsAssetable
- def self.included(base)
- base.extend ClassMethods
- end
+require 'rubygems'
+require 'active_support'
+require 'active_record'
+require 'cockpit'
+require 'acts-as-joinable'
+require 'paperclip'
+
+Paperclip::Railtie.insert
+
+this = File.expand_path(File.dirname(__FILE__))
+
+Dir["#{this}/acts-as-assetable/*"].each { |c| require c if File.extname(c) == ".rb" }
+Dir["#{this}/../app/models/*"].each { |c| require c if File.extname(c) == ".rb" }
+
+def Assets(*args, &block)
- module ClassMethods
-
- def acts_as_assetable_on(*args)
- options = args.extract_options!
- styles = args
- acts_as_joinable_on :assets, :contexts => styles
- self.class_eval do
- styles.each do |k,v|
- name = "#{k.to_s}_image"
- define_method name do
- join_for(k)
- end
-
- define_method "#{name}_id" do
- result = join_for(k)
- result ? result.id : nil
- end
-
- define_method "#{name}=" do |asset|
- set_joined(k, asset)
- end
-
- define_method "#{name}_id=" do |id|
- set_joined(k, id)
- end
- end
- end
- end
-
- def acts_as_assetable(*args)
- acts_as_assetable_on(*args)
- end
- end
-
end
+
+ActiveRecord::Base.send(:include, ActsAsAssetable) if defined?(ActiveRecord)
\ No newline at end of file