Comments (3)
It never did -- it wasn't a pain point here at Appcues, so we never ended up implementing this directly.
Since the constructor created by ExConstructor is marked by defoverridable
, the super
keyword can be used to the same effect:
iex(3)> defmodule Inner do
...(3)> defstruct [:b]
...(3)> use ExConstructor
...(3)> end
{:module, Inner, <<...>>, :ok}
iex(4)> defmodule Outer do
...(4)> defstruct [:a, :inner]
...(4)> use ExConstructor
...(4)> def new(map) do
...(4)> struct = super(map)
...(4)> %{struct | inner: Inner.new(struct.inner)}
...(4)> end
...(4)> end
{:module, Outer, <<...>>, :ok}
iex(5)> Outer.new(%{a: 1, inner: %{b: 99}})
%Outer{a: 1, inner: %Inner{b: 99}}
from exconstructor.
Hi, and thanks for the feature request! I like the syntax you've proposed, so I am going to use this as the active issue for this feature.
from exconstructor.
Did this feature ever land?
from exconstructor.
Related Issues (20)
- undefined function Mix.Utils.underscore HOT 2
- What's point of this library? HOT 2
- Is this safe to use with user input? HOT 2
- Parse upper case words HOT 9
- Support for nested structs HOT 2
- parse acronyms in jsons fields
- parsing acronyms HOT 2
- incorrect value assigned HOT 1
- Compilation deadlocks in my project when using exconstructor HOT 1
- Not checking if atom exists
- Example inline usage for the docs HOT 1
- Feature request: produce (or deconstruct) HOT 2
- Does not work with @enforce_keys
- (option to) Use Kernel.struct!/2 to be stricter about making structs HOT 1
- Is the project still active ? HOT 2
- String.to_atom/1 would not exhaust potentially the atom table? HOT 1
- Error in readme example
- String.slice and ranges - changed behaviour in Elixir 1.16.0 HOT 1
- use ExConstructor position and main example
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exconstructor.