Giter Site home page Giter Site logo

dynamic-orm-lab-v-000's Introduction

#Dynamic ORM Lab

Objectives

  1. Construct an ORM superclass that can be used for multiple classes
  2. Inherit the methods from the ORM class to the Student class

Dynamic ORMs & Inheritance

By this point, we've learned the value of a dynamic ORM -- a way to write an ORM that is almost entirely abstract. The key takeaway is that this ORM is not specific to any one class. The code will live in one class (the superclass) and be inherited to any class (child class) we wish to have access to the ORM methods.

Now that we've had some practice with this, let's build out a dynamic ORM that can be inherited to any class.

Let's get started

The Super Class

In the lib directory, you'll see the interactive_record.rb file. This file is where almost all of your ORM code will live. Once you set this up, you will share the methods in this class with the child class.

The Child Class

Your Student class lives in lib/student.rb. This class will inherit from InteractiveRecord. Your methods won't be written in this class. All of the methods defined in InteractiveRecord will be available to Student once you set up the inheritance.

Note: The only code the Student class needs to contain is the code to create the attr_accessors specific to itself. But even that code uses a method, #column_names, inherited from the super class.

This is a test-driven lab, so run the specs and get them to pass.

dynamic-orm-lab-v-000's People

Contributors

joshuabamboo avatar lizdenhup avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.