{"id":18657897,"url":"https://github.com/lightsofapollo/mappable_attributes","last_synced_at":"2025-11-05T22:30:23.432Z","repository":{"id":140858858,"uuid":"2104358","full_name":"lightsofapollo/mappable_attributes","owner":"lightsofapollo","description":"DSL to create aliases of keys in a hash","archived":false,"fork":false,"pushed_at":"2011-07-31T06:05:18.000Z","size":120,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-12-27T15:12:43.976Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lightsofapollo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-07-26T00:47:32.000Z","updated_at":"2013-10-06T15:53:08.000Z","dependencies_parsed_at":"2023-03-12T00:26:24.103Z","dependency_job_id":null,"html_url":"https://github.com/lightsofapollo/mappable_attributes","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightsofapollo%2Fmappable_attributes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightsofapollo%2Fmappable_attributes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightsofapollo%2Fmappable_attributes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightsofapollo%2Fmappable_attributes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lightsofapollo","download_url":"https://codeload.github.com/lightsofapollo/mappable_attributes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239475960,"owners_count":19645041,"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":[],"created_at":"2024-11-07T07:30:18.526Z","updated_at":"2025-11-05T22:30:23.395Z","avatar_url":"https://github.com/lightsofapollo.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# What is MappableAttributes?\n\nOften I find myself needing to rename the keys of one hash into another.\n\nA trival example of this looks like:\n\n\n    hash1 = {:werid_name =\u003e 'value'}\n    hash2 = {:name =\u003e hash1[:werid_name]}\n\nIf you only need to rename one or two keys a simple approach like the\nabove is fine.\n\nThis library was designed for my need of renaming multiple\nfields with extensability via blocks and by inherting from MappableAttributes::Base.\n\nAn example on a sudo Model.\n\n\n    class SudoModel\n      \n      @@renamer = MappableAttributes::Base.new do\n        \n\n        map :output_name =\u003e :input_name\n        map :another_name do |input|\n          input[:input_name].downcase\n        end\n\n        # ....\n\n      end\n\n      def attributes\n        {\n          :input_name =\u003e 'FIRST LAST'\n        }\n      end\n\n      def export_attributes\n        @renamer.map_attributes(attributes)\n        # =\u003e\n        # {\n        #   :output_name =\u003e 'FIRST LAST',\n        #   :another_name =\u003e 'first last'\n        # }\n      end\n\n    end\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flightsofapollo%2Fmappable_attributes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flightsofapollo%2Fmappable_attributes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flightsofapollo%2Fmappable_attributes/lists"}