{"id":20496413,"url":"https://github.com/hardpixel/active-delegate","last_synced_at":"2025-04-13T18:21:16.399Z","repository":{"id":59150285,"uuid":"92771750","full_name":"hardpixel/active-delegate","owner":"hardpixel","description":"Delegate ActiveRecord model attributes and associations.","archived":false,"fork":false,"pushed_at":"2022-05-28T08:00:58.000Z","size":84,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T09:04:36.387Z","etag":null,"topics":["activerecord","delegate","rails","ruby-gem"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hardpixel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-29T20:07:34.000Z","updated_at":"2024-01-20T18:59:58.000Z","dependencies_parsed_at":"2022-09-13T11:00:32.003Z","dependency_job_id":null,"html_url":"https://github.com/hardpixel/active-delegate","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardpixel%2Factive-delegate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardpixel%2Factive-delegate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardpixel%2Factive-delegate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardpixel%2Factive-delegate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hardpixel","download_url":"https://codeload.github.com/hardpixel/active-delegate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248516930,"owners_count":21117352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activerecord","delegate","rails","ruby-gem"],"created_at":"2024-11-15T18:07:03.930Z","updated_at":"2025-04-13T18:21:16.382Z","avatar_url":"https://github.com/hardpixel.png","language":"Ruby","readme":"# ActiveDelegate\n\nStores and retrieves delegatable data through attributes on a ActiveRecord class, with support for translatable attributes.\n\n[![Gem Version](https://badge.fury.io/rb/active_delegate.svg)](https://badge.fury.io/rb/active_delegate)\n[![Build Status](https://travis-ci.org/hardpixel/active-delegate.svg?branch=master)](https://travis-ci.org/hardpixel/active-delegate)\n[![Code Climate](https://codeclimate.com/github/hardpixel/active-delegate/badges/gpa.png)](https://codeclimate.com/github/hardpixel/active-delegate)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'active_delegate'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install active_delegate\n\n## Usage\n\n```ruby\nclass Address \u003c ActiveRecord::Base\n  # columns: :city, :district\nend\n\nclass Person \u003c ActiveRecord::Base\n  # columns: :name, email, :phone, :address_id\n\n  include ActiveDelegate\n\n  belongs_to :address\n  has_one    :user\n  has_many   :books\n\n  delegate_attributes to: :address, prefix: true, localized: true\nend\n\nparams = {\n  name:                'John',\n  email:               'john@mail.com',\n  address_city:        'Athens',\n  address_city_el:     'Αθήνα',\n  address_district:    'Attiki',\n  address_district_el: 'Αττική'\n}\n\nperson = Person.new(params)\n\nperson.name                # 'John'\nperson.address_city        # 'Athens'\nperson.address.city        # 'Athens'\nperson.address_city_el     # 'Αθήνα'\nperson.address.city_el     # 'Αθήνα'\nperson.address_district    # 'Attiki'\nperson.address.district    # 'Attiki'\nperson.address_district_el # 'Αττική'\nperson.address.district_el # 'Αττική'\n\nclass User \u003c ActiveRecord::Base\n  # columns: :login, :password, :person_id\n\n  include ActiveDelegate\n\n  belongs_to :person, autosave: true\n\n  delegate_associations to: :person\n  delegate_attributes   to: :person\nend\n\nparams = {\n  login:    'jonian',\n  password: 'passwd',\n  name:     'John',\n  email:    'john@mail.com'\n}\n\nuser = User.new(params)\n\nuser.name           # 'John'\nuser.login          # 'jonian'\nuser.user           # @user\nuser.books          # []\n\nuser.email          # 'john@mail.com'\nuser.email?         # true\nuser.email_changed? # true\nuser.email_was      # nil\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/hardpixel/active-delegate.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardpixel%2Factive-delegate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhardpixel%2Factive-delegate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardpixel%2Factive-delegate/lists"}