Sha256: 47c1ce1044f21bcd1311038aa3cb98ce122d082d5cb2cefb1bc7867f5921b0ee

Contents?: true

Size: 730 Bytes

Versions: 3

Compression:

Stored size: 730 Bytes

Contents

module Refinery
  module VimeoVideos
    module ActiveRecord
  
      def vimeo_video field
        class_eval <<-EOV
    
          def #{field}
            if self.new_record?
              self.#{field}_id
            else
              self.#{field}_id? ? VimeoMetaCache.find_or_create_by_vid(self.#{field}_id) : nil
            end
          end
      
          before_save :cache_vimeo_meta_for_#{field}
      
          def cache_vimeo_meta_for_#{field}
            if self.#{field}_id? and self.#{field}_id_changed?
              VimeoMetaCache.find_or_create_by_vid(self.#{field}_id)
            end
          end
          protected :cache_vimeo_meta_for_#{field}
      
        EOV
      end
        
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
refinerycms-vimeo-videos-0.1.9.rc3 lib/refinerycms-vimeo-videos/active_record.rb
refinerycms-vimeo-videos-0.1.9.rc2 lib/refinerycms-vimeo-videos/active_record.rb
refinerycms-vimeo-videos-0.1.9.rc1 lib/refinerycms-vimeo-videos/active_record.rb