Sha256: f3e3b38a1f3b6f27e51c96816336a0f545a324b43cc940ec41e37e5e8efb7b9c
Contents?: true
Size: 605 Bytes
Versions: 1
Compression:
Stored size: 605 Bytes
Contents
require 'active_record/base' module Watarase module Model def self.included(model) model.extend Watarase::ActsAsImageHandler end end module ActsAsImageHandler def acts_as_image_handler _image_holder = (self.name.underscore << '_' << Watarase.suffix).to_sym self.send(:has_one, _image_holder, primary_key: self.primary_key, foreign_key: "#{self.name.underscore}_#{self.primary_key}", autosave: true) self.send(:attr_accessor, :remove_image) end end end ActiveRecord::Base.send :include, Watarase::Model unless ActiveRecord::Base.include? Watarase::Model
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
watarase-0.0.2 | lib/watarase/model.rb |