foobara 0.0.35 → 0.0.36
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -1
- data/README.md +59 -0
- data/projects/detached_entity/src/concerns/associations.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 796f1d29d3a7ab80b6ae136f254a80549a75ec952ec1219701960abe24bd1256
|
4
|
+
data.tar.gz: c99fc6d286203521a9242dbc7ed042a27161b12fb213eec3b44c02f4cca26236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd63e1dfe5afab9b6b29c855352d3db79a1fa4c04f912c385eeeeb187d2bedbf558fa929d021b276b510ce8d9b62aa4d41da92f8fba7aa6d12e6b752b47d80db
|
7
|
+
data.tar.gz: 992b76e3ba595df506570c311a93174e9745ed9e9f5af310cd3b56c1b0274b668f4f38bd3344499c11dd352b5e37ab7bf400ef4421e0b9810d774f91290505c7
|
data/CHANGELOG.md
CHANGED
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[:
|
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
|