active-hash / active-hash/active_hash

support has_many in YAML sources

Open
#94 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
1.4k
Forks
186
PR merge metrics
No merged PRs in 30d

Description

class Plans::IsoDistro < ActiveYaml::Base
  include ActiveHash::Associations
  has_many :iso_images, class_name: 'Plans::IsoImage'
end

class Plans::IsoImage < ActiveHash::Base
  include ActiveHash::Associations
  belongs_to :iso_distro, class_name: 'Plans::IsoDistro'
end
- id: 1
  code: arch
  name: Arch Linux
  iso_images:
    - path: archlinux.iso
      bit: 64
    - path: ubuntu.iso
      bit: 32

@isos.first
=> #<Plans::IsoDistro:0x007f75b8962348 @attributes={:id=>1, :code=>"arch", :name=>"Arch Linux", :iso_images=>[{"path"=>"archlinux.iso", "bit"=>64}, {"path"=>"ubuntu.iso", "bit"=>32}]}>
@isos.first.iso_images
=> []

This could understand nested structures and create IsoImage objects too, along with an appropriate relation.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how YAML sources are loaded and how the existing has_many and belongs_to associations resolve records; the issue provides the Plans::IsoDistro and Plans::IsoImage entry points and nested YAML example. Done means nested iso_images produce IsoImage objects and @isos.first.iso_images returns the appropriate relation, with behavior covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.