Module: Neo4jrb::Paperclip::ClassMethods

Defined in:
lib/neo4jrb_paperclip.rb

Instance Method Summary collapse

Instance Method Details

#after_commit(*args, &block) ⇒ Object

Adds after_commit



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/neo4jrb_paperclip.rb', line 59

def after_commit(*args, &block)
  options = args.pop if args.last.is_a? Hash
  if options
    case options[: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



104
105
106
107
# File 'lib/neo4jrb_paperclip.rb', line 104

def has_attached_file(field, options = {})
  raise "Neo4jrb::Paperclip#has_attached_file is deprecated, " +
    "Use 'has_neo4jrb_attached_file' instead"
end

#has_neo4jrb_attached_file(field, options = {}) ⇒ Object

Adds Neo4jrb::Paperclip’s “#has_neo4jrb_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
# File 'lib/neo4jrb_paperclip.rb', line 82

def has_neo4jrb_attached_file(field, options = {})

  ##
  # Include Paperclip and Paperclip::Glue for compatibility
  include ::Paperclip
  include ::Paperclip::Glue

  ##
  # Invoke Paperclip's #has_attached_file method and passes in the
  # arguments specified by the user that invoked Neo4jrb::Paperclip#has_neo4jrb_attached_file
  has_attached_file(field, options)

  ##
  # Define the necessary collection fields in Neo4jrb 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
end