Module: Neo4jrb::Paperclip::ClassMethods
- Defined in:
- lib/neo4j_paperclip.rb
Instance Method Summary collapse
-
#after_commit(*args, &block) ⇒ Object
Adds after_commit.
-
#has_attached_file(field, options = {}) ⇒ Object
This method is deprecated.
-
#has_neo4j_attached_file(field, options = {}) ⇒ Object
Adds Neo4jrb::Paperclip’s “#has_neo4j_attached_file” class method to the model which includes Paperclip and Paperclip::Glue in to the model.
Instance Method Details
#after_commit(*args, &block) ⇒ Object
Adds after_commit
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/neo4j_paperclip.rb', line 60 def after_commit(*args, &block) = args.pop if args.last.is_a? Hash if case [:on] when :create after_create(*args, &block) when :update after_update(*args, &block) when :destroy after_destroy(*args, &block) else after_save(*args, &block) end else after_save(*args, &block) end end |
#has_attached_file(field, options = {}) ⇒ Object
This method is deprecated
106 107 108 109 |
# File 'lib/neo4j_paperclip.rb', line 106 def has_attached_file(field, = {}) raise "Neo4jrb::Paperclip#has_attached_file is deprecated, " + "Use 'has_neo4jrb_attached_file' instead" end |
#has_neo4j_attached_file(field, options = {}) ⇒ Object
Adds Neo4jrb::Paperclip’s “#has_neo4j_attached_file” class method to the model which includes Paperclip and Paperclip::Glue in to the model. Additionally it’ll also add the required fields for Paperclip since MongoDB is schemaless and doesn’t have migrations.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/neo4j_paperclip.rb', line 82 def has_neo4j_attached_file(field, = {}) ## # Include Paperclip and Paperclip::Glue for compatibility unless self.ancestors.include?(::Paperclip) include ::Paperclip include ::Paperclip::Glue end ## # Invoke Paperclip's #has_attached_file method and passes in the # arguments specified by the user that invoked Neo4jrb::Paperclip#has_neo4j_attached_file has_attached_file(field, ) ## # Define the necessary collection fields in Mongoid for Paperclip property :"#{field}_file_name", :type => String property :"#{field}_content_type", :type => String property :"#{field}_file_size", :type => Integer property :"#{field}_updated_at", :type => DateTime property :"#{field}_fingerprint", :type => String end |