app/models/ckeditor/asset.rb in fullstack-ckeditor-0.1.1 vs app/models/ckeditor/asset.rb in fullstack-ckeditor-0.1.2

- old
+ new

@@ -1,4 +1,44 @@ class Ckeditor::Asset < ActiveRecord::Base - include Ckeditor::Orm::ActiveRecord::AssetBase - include Ckeditor::Backend::Paperclip -end + belongs_to :assetable, :polymorphic => true + inheritable + timestamps + + + def filename + data_file_name + end + + def has_dimensions? + respond_to?(:width) && respond_to?(:height) + end + + def image? + Ckeditor::IMAGE_TYPES.include?(data_content_type) + end + + def format_created_at + self.created_at.strftime("%d.%m.%Y") + end + + def url_content + url + end + + def url_thumb + url(:thumb) + end + + def as_json_methods + [:url_content, :url_thumb, :size, :filename, :format_created_at] + end + + def as_json(options = nil) + options = { + :methods => as_json_methods, + :root => "asset" + }.merge(options || {}) + + super options + end + +end \ No newline at end of file