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

make-private

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

make-private

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

make-private

make-private is an ActiveRecord extension that will make all your active record properties private and give you control over what is private and what should be public.

Why make-private

By default active record makes all properties and associations public which does make it faster to develop with but breaks encapsulation by default. make-private has been developed to bring back encapsulation to active record model.

Status

make-private is currently in development

Example

To use make-private private you simply have to include the module in your model, simple.

require 'make-private'

class BusinessModel < ActiveRecord::Base
  #a_property: string
  include MakePrivate

end

business_model = BusinessModel.new
business_model.a_property # This will throw a NoMethodError exception

Properties can be set as normal from within the model

require 'make-private'

class BusinessModel < ActiveRecord::Base
  #a_property: string
  include MakePrivate

  def do_something_useful parameter
    ##some logic
    self.a_property = parameter
  end

end

If you require to make a property publicly readable set the method to public

require 'make-private'

class BusinessModel < ActiveRecord::Base
  #a_property: string
  include MakePrivate

  public :a_property
end

business_model = BusinessModel.new
business_model.a_property # This will no longer throw a NoMethodError exception
business_model.a_property = "something interesting" # This will still throw a NoMethodError exception

Similarly if you really really really need to make the property setter public.

require 'make-private'

class BusinessModel < ActiveRecord::Base
  #a_property: string
  include MakePrivate

  public :a_property, :a_property=
end

business_model = BusinessModel.new
business_model.a_property # This will no longer throw a NoMethodError exception
business_model.a_property = "something interesting" # This will not throw a NoMethodError exception

##Notes

Please send any questions, comments or feedback to pythonandchips{at}gmail.com.

Cheers Colin

FAQs

Package last updated on 16 Oct 2011

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