foobara 0.0.35 → 0.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2cf6302b2afba48242f5cc283a4029ebb6337cccc367a633752cd9866c69d69
4
- data.tar.gz: 05b4068afedd82c0712e977d9810ebc1bcacb9c06ab90205e1985966f5ece820
3
+ metadata.gz: 796f1d29d3a7ab80b6ae136f254a80549a75ec952ec1219701960abe24bd1256
4
+ data.tar.gz: c99fc6d286203521a9242dbc7ed042a27161b12fb213eec3b44c02f4cca26236
5
5
  SHA512:
6
- metadata.gz: 48722536d6aee98bebaad5934153c5d46223857343292054f6f053c80a7784d187f853514bb3271831c6158056490326731501d2a890d51a386c6626cbd76932
7
- data.tar.gz: 1371ff6d6b3a81b4cf7228f6cd15a70265955da87dca6bcc580a938217f2443d3add0f8aaad85e705cca00cb101cb8587723360ada4f8a9b765895400d4b44e6
6
+ metadata.gz: bd63e1dfe5afab9b6b29c855352d3db79a1fa4c04f912c385eeeeb187d2bedbf558fa929d021b276b510ce8d9b62aa4d41da92f8fba7aa6d12e6b752b47d80db
7
+ data.tar.gz: 992b76e3ba595df506570c311a93174e9745ed9e9f5af310cd3b56c1b0274b668f4f38bd3344499c11dd352b5e37ab7bf400ef4421e0b9810d774f91290505c7
data/CHANGELOG.md CHANGED
@@ -1,7 +1,8 @@
1
- ## [0.0.35] - 2024-12-10
1
+ ## [0.0.36] - 2024-12-10
2
2
 
3
3
  - Fix bug with command-named convenience functions
4
4
  - Make domain mappers cast their inputs
5
+ - Exclude detached entities from associations
5
6
 
6
7
  ## [0.0.33] - 2024-12-09
7
8
 
data/README.md CHANGED
@@ -1419,10 +1419,60 @@ Normally, we wouldn't make use of a domain mapper in isolation. Like everything
1419
1419
  of a command. But we can play with it directly:
1420
1420
 
1421
1421
  ```irb
1422
+ $ ./animal_house_import.rb
1423
+ > create_capybara_inputs = FoobaraDemo::CapyCafe::AnimalToCapybara.call(species: :capybara, first_name: "Barbara", last_name: "Doe", birthday: "1000-01-01")
1424
+ ==> {:name=>"Barbara Doe", :age=>1024}
1425
+ > barbara = FoobaraDemo::CapyCafe::CreateCapybara.run!(create_capybara_inputs)
1426
+ ==> <Capybara:2>
1427
+ > barbara.age
1428
+ ==> 1024
1429
+ > barbara.id
1430
+ ==> 2
1431
+ ```
1422
1432
 
1433
+ And we can increment Barbara's age now that she has been imported into our CapyCafe:
1434
+
1435
+ ```irb
1436
+ > FoobaraDemo::CapyCafe::IncrementAge.run!(capybara: barbara)
1437
+ ==> <Capybara:2>
1438
+ > FoobaraDemo::CapyCafe::FindCapybara.run!(id: barbara)
1439
+ ==> <Capybara:2>
1440
+ > FoobaraDemo::CapyCafe::FindCapybara.run!(id: barbara).age
1441
+ ==> 1025
1423
1442
  ```
1424
1443
 
1444
+ Now let's create a command that makes use of our domain mapper which is the typical usage pattern:
1445
+
1425
1446
  ```ruby
1447
+ #!/usr/bin/env ruby
1448
+
1449
+ require "foobara/remote_imports"
1450
+
1451
+ [9292, 9293].each do |port|
1452
+ Foobara::RemoteImports::ImportCommand.run!(manifest_url: "http://localhost:#{port}/manifest")
1453
+ end
1454
+
1455
+ module FoobaraDemo
1456
+ module AnimalHouse
1457
+ foobara_domain!
1458
+ end
1459
+ end
1460
+
1461
+ module FoobaraDemo
1462
+ module AnimalHouse
1463
+ class Animal < Foobara::Model
1464
+ attributes do
1465
+ first_name :string
1466
+ last_name :string
1467
+ birthday :date
1468
+ species :symbol, one_of: %i[capybara cat tartigrade]
1469
+ end
1470
+ end
1471
+ end
1472
+ end
1473
+
1474
+ module FoobaraDemo
1475
+ module CapyCafe
1426
1476
  class ImportAnimal < Foobara::Command
1427
1477
  class NotACapybara < Foobara::DataError
1428
1478
  context species: :symbol, animal: AnimalHouse::Animal
@@ -1459,8 +1509,17 @@ of a command. But we can play with it directly:
1459
1509
  self.capybara = run_mapped_subcommand!(CreateCapybara, animal)
1460
1510
  end
1461
1511
  end
1512
+ end
1513
+ end
1462
1514
  ```
1463
1515
 
1516
+ Note that we can automatically map `animal` to CreateCapybara inputs by calling `#run_mapped_subcommand!`
1517
+
1518
+ Let's play with it:
1519
+
1520
+ ```irb
1521
+
1522
+ ```
1464
1523
  TODO
1465
1524
 
1466
1525
  ### Code Generators
@@ -114,7 +114,7 @@ module Foobara
114
114
  path = DataPath.new,
115
115
  result = {}
116
116
  )
117
- if type.extends?(BuiltinTypes[:detached_entity])
117
+ if type.extends?(BuiltinTypes[:entity])
118
118
  result[path.to_s] = type
119
119
  elsif type.extends?(BuiltinTypes[:tuple])
120
120
  element_types = type.element_types
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.35
4
+ version: 0.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi