Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

acts_as_file

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acts_as_file

  • 0.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Acts as file

acts_as_file makes your field act as a file. The content of the field is stored into a file on calling #save method, and is loaded from the file on calling its accessor method.

Build Status Coverage Status

Installation

Add the following to your Gemfile:

gem 'acts_as_file'

And then execute:

$ bundle

Examples

ActiveRecord is not required, but let me write an example for it.

class Post < ActiveRecord::Base
  include ActsAsFile
  def filename
    "posts/#{self.id}_body.txt"
  end
  acts_as_file :body => self.instance_method(:filename)
end

# store
post = Post.new
post.body = 'content'
post.save # save the content into the file of `#filename`
          # create the directory if not exist
# load
post = Post.first
puts post.body # load the content from the file of `#filename`
post.destroy   # remove the file

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
  • Copyright (c) 2014 Naotoshi Seo. See LICENSE for details.

FAQs

Package last updated on 28 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc