Sha256: ff7f4119d51ca15181726c4c1e633d0904e0b8d7d7eb96409e9ade7e3ed4bfac
Contents?: true
Size: 965 Bytes
Versions: 1
Compression:
Stored size: 965 Bytes
Contents
module ActsAsAssetable def self.included(base) base.extend ClassMethods end module ClassMethods def acts_as_assetable_on(*args) options = args.extract_options! styles = options[:styles] 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(:parent, :asset, k) end define_method "#{name}_id" do result = join_for(:parent, :asset, k) result ? result.id : nil end define_method "#{name}=" do |asset| set_joined(:parent, :asset, k, asset) end define_method "#{name}_id=" do |id| set_joined(:parent, :asset, k, id) end end end end def acts_as_assetable(*args) acts_as_assetable_on(*args) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts-as-assetable-0.0.2.1 | lib/acts-as-assetable/acts_as_assetable.rb |