Git Product home page Git Product logo

Comments (9)

locochris avatar locochris commented on June 8, 2024

@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.

stevenharman avatar stevenharman commented on June 8, 2024

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.

fredwu avatar fredwu commented on June 8, 2024

I like the block level style, it is explicit, readable and doesn't require more keystrokes. :)

from datamappify.

locochris avatar locochris commented on June 8, 2024

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.

stevenharman avatar stevenharman commented on June 8, 2024

@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.

locochris avatar locochris commented on June 8, 2024

@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.

fredwu avatar fredwu commented on June 8, 2024

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.

stevenharman avatar stevenharman commented on June 8, 2024

@fredwu That seems reasonable.

from datamappify.

fredwu avatar fredwu commented on June 8, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.