Comments (9)
@stevenharman what about:
using 'ActiveRecord' do
map_attribute :account_username, to: 'UserAccount#username'
end
Or using some nice convention over configuration defaults:
using 'ActiveRecord' do
map_attribute :user_account__username
end
from datamappify.
I suppose wrapping the config in a block where you specify a local default provider is kind of nice for when you want to map many things at once. Though the more verbose :with
option is also nice for a single, or just a few, mappings.
I don't really like the double underscore to denote the method name.
from datamappify.
I like the block level style, it is explicit, readable and doesn't require more keystrokes. :)
from datamappify.
So best of all worlds?
ie. allow using a block, or the more verbose single option. :)
Agreed, that double underscore doesn't look pretty...
How bout drying it up another way:
using 'ActiveRecord' do
mapping 'UserAccount', :prefix => :account do
map_attribute :username
end
end
Or what about:
mapping 'UserAccount', :prefix => :account, :using => 'ActiveRecord' do
map_attribute :username
end
from datamappify.
@fredwu, Number of keystrokes seems an odd thing to optimize for, over intent and clarity. π
@locochris, Remember:
DRY isnβt about the repetition of structure, itβs about the duplication of knowledge.
At any rate, of the block syntaxes, I prefer the last one, I think. Even then, the :using
option could default to the specified default_provider
.
β€οΈ for the communication and feedback, all.
from datamappify.
@stevenharman if you go with the default_provider
idea it'd probably make more sense to
compliment that by using the word :provider
instead of :using
from datamappify.
How about this?
with_provider :ActiveRecord do
map_attribute :account_username, to: 'UserAccount#username'
end
# and
map_attribute :account_username, to: 'UserAccount#username', :with_provider: :ActiveRecord
from datamappify.
@fredwu That seems reasonable.
from datamappify.
FYI I'm going to let the :via
option act the same way, in that case I think I will make it:
group :provider: :ActiveRecord, via: :user_id do
map_attribute :account_username, to: 'UserAccount#username'
end
# and
map_attribute :account_username, to: 'UserAccount#username', :provider: :ActiveRecord, via: :user_id
from datamappify.
Related Issues (20)
- Does it work for Rails3?
- Timestamps HOT 1
- Question: Do I need a Database table for each Entity HOT 4
- UUID primary keys HOT 1
- Load entity relations HOT 7
- Add support for Her HOT 1
- Change behaviour of default_provider HOT 7
- Why isn't this gem 1.0.0? HOT 3
- ActiveRecord - match mapped attribute missing joins HOT 2
- Question: Integration with Padrino HOT 1
- change implicit table HOT 3
- why not only support rails 4.0 ? HOT 2
- Datamappify::Lazy causing errors with has_many
- Maintained? HOT 4
- Hi Fred! HOT 1
- for_entity namespace HOT 1
- Devise HOT 2
- NameError: uninitialized constant Datamappify::Entity HOT 1
- NoMethodError: undefined method `split' for nil:NilClass HOT 1
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 datamappify.