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

lazy_attributes

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazy_attributes

  • 0.0.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

LazyAttributes

lazy_attributes is an ActiveRecord plugin. lazy_attributes loads lazily specified attributes.

Build
Status Gem Version

This gem is heavily inspired by lazy_columns.

Installation

Add this line to your application's Gemfile:

gem 'lazy_attributes'

And then execute:

$ bundle

Or install it yourself as:

$ gem install lazy_attributes

Usage

In Active Record model, specify attributes that are needed to be loaded lazyly with lazy_attributes:

class User < ActiveRecord::Base
  lazy_attributes :profile
  lazy_attributes :address, :bio
end

When model with lazyly-loaded attributes is associated with another model, you need specify scope for association with '.column_symbols_without_lazy'.

class Group < ActiveRecord::Base
  has_many :users, { select(User.column_symbols_without_lazy) }
end

For Rails 3.2, use select option.

class Group < ActiveRecord::Base
  has_many :users, select: User.column_symbols_without_lazy
end

TODO

  • Reload only attribute that is referenced
  • Clean up code and specs

Contributing

  1. Fork it ( https://github.com/[my-github-username]/lazy_attributes/fork )
  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 a new Pull Request

FAQs

Package last updated on 09 Jun 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