New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

if_it_werent_4_AR

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

if_it_werent_4_AR

  • 0.0.9
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

If it were not for ActiveRecord

A test task with minimum functionality to demonstrate basic knowledge and understanding of the AR pattern.

  • Records are stored directly in filesystem
  • Storage CRUD functionality and search capabilities
  • Minimalistic error handler
  • SerDes
  • Generator for creating models
  • Simple associations

Version

0.0.3

Details

  • Storage
    • Common dataset schema is stored under db/schema_IFWN4AR.yml. Each first level key represents a model. The second level keys stand for attributes and their values are their types correspondingly. Convention has it that keys(table names) should be the singular of the entity that they store attributes of.
    • Each dataset is stored under 'db/DATASET_NAME_storage.csv' (CSVs' must have a header)
    • id must be present in schema as the first attribute.
    • Only integer and text types are supported.
  • SerDes
    • Object serializes in a string where attributes have tabulation symbol between. Be sure to not put tabulation in object attributes.
  • Associations
  • belongs_to, has_many associations supported. In order to use them you need to assign them in models as class instance variavles and restart server.
class User < IfItWerent4AR::Base
  @has_many = [MobilePhone, Passport]
end

Installation

Add to your gemfile:

gem 'if_it_werent_4_AR', '>=0.0.6'

Add schema file db/schema_IFWN4AR.yml

user:
  id: integer
  name: text
mobile_phone:
  id: integer
  user_id: integer
book:
  id: integer
  author_id: integer
  content: text
author:
  id: integer
  name: text

Run generator to create Model, storage if not exists with appropriate headers.

rails generate iitw4ar

TODOs

  • Don't hardcode serialization delimiter
  • Add tests
  • Optimize storage solution
  • Add validations
  • Add ability to change primary/foreign keys
  • Add id auto incrementation
  • Add callbacks
  • A lot

Features

  • When a record is being deleted in the storage an empty string remains.
  • Objects with the same attributes are considered equal(same object).
  • When trying to get associations for a record (class instance) with an id existing in storage, associations will be fetched for that record in storage.

By

Azat Gataoulline

Source

[https://github.com/Gataniel/if_it_werent_4_AR.git]

License

MIT

FAQs

Package last updated on 07 Feb 2016

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