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

datts_right

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datts_right

  • 0.0.32
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

h1. Datts Right

bq. Dynamic Attributes Done Right

Well, maybe it's done right. This gem is more of an experiment at the moment. I also did this to learn more about metaprogramming.

I would like input from you guys. Is this something that is too messy?

h2. Why make this?

I needed to allow users to create their own dynamic attributes on certain records. I was already running PostgreSQL. My database and code was designed largely on relational structures. I was thinking of moving to MongoDB but saw that I'd pretty much have to rewrite all the models. Creating this gem was the first step to using dynamic attributes on my app.

The "available":http://codaset.com/joelmoss/dynamic-attributes "plugins":https://github.com/moiristo/dynamic_attributes out there that did something like this stuffed the dynamic attributes in a column in the model that had dynamic attributes. Because of this, you:

** Could not order things by dynamic columns straight with SQL ** Could not (as far as I know) chain scopes, like so: @MyModel.where(:name_which_is_a_real_attribute => "Joe").where_dynamic_attribute(:phone_which_is_dynamic => "23218793")@ ** Could not find by dynamic attribute straight with SQL, like so: @MyModel.find_by_dynamic_attribute_phone_which_is_dynamic("2398291308")@ ** Had to add migrations to each model that you wanted to have dynamic attributes

h2. Contributing to dynamic_attributes_right

There are definitely things that don't work, and could be done better. For example, it would be nice to:

Do away with the special scopes, such as @where_dynamic_attribute@ and @order_by_dynamic_attribute@. I've tried to override ActiveRecord to make the normal @where@ and @order@ methods to see if the attributes being passed were dynamic, and do the changes necessary to the resulting SQL, but my head "started to hurt":http://stackoverflow.com/q/5590191/61018.

Have smarter caching, so that finds with dynamic attributes aren't very expensive.

Have configurable "dynamic_attributes" table

Warning: the code is full of comments because I needed to visualize the code running.

If you want to contribute:

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

h2. Copyright

Copyright (c) 2011 Ramon Tayag. See LICENSE.txt for further details.

FAQs

Package last updated on 28 Apr 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