boba 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/tapioca/compilers/money_rails.rb +54 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3bfe9d8d1884d0b76b245e52f84f91700c9f0912e263c20aeb9cfc0450c82494
|
4
|
+
data.tar.gz: c99aff34c22dad11aaae294470abf382327529c699a0ed88b1785f7217a60ac3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f9464beb95f46c3a9afca5d6278a8b4635561a12a664173037d96bce31f995bd2d5a1c285bb78dd40033bd74f095a3e26a3c5bbfdbccbb3c6d6e352efe664445
|
7
|
+
data.tar.gz: f9efcb9b2128e95d05ee67b1242359c2662ccaa03e0058b771c774d87f8097ddbdf3c8634c750bf6ad58c64d845ab6b98bcf3b59c3f871cf49236146e61fc33d
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: true
|
3
|
+
|
4
|
+
require 'tapioca/helpers/rbi_helper'
|
5
|
+
|
6
|
+
module Tapioca
|
7
|
+
module Dsl
|
8
|
+
module Compilers
|
9
|
+
class MoneyRails < Tapioca::Dsl::Compiler
|
10
|
+
extend T::Sig
|
11
|
+
include RBIHelper
|
12
|
+
|
13
|
+
ConstantType = type_member {{ fixed: T.class_of(::MoneyRails::ActiveRecord::Monetizable) }}
|
14
|
+
|
15
|
+
class << self
|
16
|
+
extend T::Sig
|
17
|
+
|
18
|
+
sig { override.returns(T::Enumerable[Module]) }
|
19
|
+
def gather_constants
|
20
|
+
all_classes.select { |c| c < ::MoneyRails::ActiveRecord::Monetizable }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
sig { override.void }
|
25
|
+
def decorate
|
26
|
+
root.create_path(constant) do |klass|
|
27
|
+
instance_module_name = 'MoneyRailsGeneratedMethods'
|
28
|
+
instance_module = RBI::Module.new(instance_module_name)
|
29
|
+
|
30
|
+
constant.monetized_attributes.each do |attribute_name, column_name|
|
31
|
+
column = T.unsafe(constant).columns_hash[column_name]
|
32
|
+
|
33
|
+
type_name = '::Money'
|
34
|
+
type_name = as_nilable_type(type_name) if column.nil? || !!column.null
|
35
|
+
|
36
|
+
# Model: monetize :amount_cents
|
37
|
+
# => amount
|
38
|
+
# => amount=
|
39
|
+
instance_module.create_method(attribute_name, return_type: type_name)
|
40
|
+
instance_module.create_method(
|
41
|
+
"#{attribute_name}=",
|
42
|
+
parameters: [create_param('value', type: type_name)],
|
43
|
+
return_type: type_name,
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
klass << instance_module
|
48
|
+
klass.create_include(instance_module_name)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: boba
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Angellist
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-09-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sorbet-static-and-runtime
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tapioca
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.16'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.16'
|
41
|
+
description:
|
42
|
+
email: alex.stathis@angellist.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- lib/tapioca/compilers/money_rails.rb
|
48
|
+
homepage: https://rubygems.org/gems/hola
|
49
|
+
licenses: []
|
50
|
+
metadata: {}
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 3.0.0
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubygems_version: 3.5.16
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: Compilers, RBIs, and other files accompanying Sorbet & Tapioca.
|
70
|
+
test_files: []
|