Releases: onthebeach/structural
Releases · onthebeach/structural
Release list
Allow has_one association to support default option
Currently has_one always raises an error if the key isn't passed
in as data. This change allows a default to be specified that will
be used when initializing the associated structural class.
One use-case for this is to allow the creation of naive structural
classes with nested associations.
class CustomerDetails
field :account_name, default: nil
has_one :credentials, default: {}, type: Credentials
has_one :billing_address, default: {}, type: BillingAddress
def name
account_name || credentials.name || billing_address.name
end
endIn the above snippet, we know that there are three ways to pass the
customer's name: as top-level account_name, as name nested in
credentials or as name nested in billing_address.
Having a default allows you to specify a single access point that
attempts to access the data from the various sources.
Version 0.1.0 (November 7th 2016)
Reduce the number of objects allocations #4