Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@craigmcnamara
Copy link
Contributor

Implement a table name scoped obfuscation config

@nettofarah
Copy link
Contributor

Nice! You're on fire! :)

I'm not sure if I like this design better than the one you proposed on #29.

I'll think about this some more before I weigh in..

We need to make sure this is backwards compatible though (I'm assuming it is)

@craigmcnamara
Copy link
Contributor Author

Yea, this works with the existing config format. I think I'm more of a fan of this because it's very easy to implement and easy to explain.

At the moment I'm implementing a pretty large project with Polo so I'm adding things as I find I need them. If I think I need the other config style I'll whip it up and send a pull request.

@nettofarah
Copy link
Contributor

This is a good point. The string option is much easier to explain and implement.
And I like simplicity 🤓

So this API might be a winner.

@nettofarah
Copy link
Contributor

Just thought of something else...
What happens when someone uses self.table_name = something in one of their models?

Should we use the table name or model name in this case?

I'm inclined to think that it should be the model name since we're operating on models. Also probably simpler to implement.

A philosofical reason to operate on model names is the fact that Polo transforms AR records into SQL statments (Not the other way around)

@craigmcnamara
Copy link
Contributor Author

'table.column' is the correct SQL selector for a model configured with self.table_name = something and to me it seems consistent with ActiveRecord query conventions. Ex: http://guides.rubyonrails.org/active_record_querying.html#group

.

@nettofarah
Copy link
Contributor

I see..
I'm just not sure if this is the route we want to go.

I think we should standardize on model names as opposed to the table name, mostly because Polo isn't too worried about what table those selects are coming from, especially now that we started using Arel for the generation.

We could probably change the line where you do:

instance.class.table_name == table

to something like

 if klass = class_name(field)
   field = field_name(field)
end

instance.class.name == klass

@craigmcnamara
Copy link
Contributor Author

So the specs have namespaced models like AR::Ingredient to make that work the string format would have to be obfuscate 'AR::Ingredient.name' => -> (i) { "Secret" } instead of obfuscate 'ingredients.name' => -> (i) { "Secret" }.

I think the SQL convention is more intuitive for advanced usage since the ActiveRecord pattern is to expose SQL when things stop being simple. Either way it provides a needed capability and I'll update the README accordingly.

@nettofarah
Copy link
Contributor

that's a good point.
table names would probably make things simpler, I guess they can't get too fancy, not as much as class names at least.

This sounds good!
Let's update the README file and merge this in!

Thanks again, @craigmcnamara

@craigmcnamara
Copy link
Contributor Author

Docs updated!

README.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a line that clarifies the difference between regular fields vs namespaced ones?
i.e. a naked field will by applied across every table, vs a namespaced one only being applied to that specific table.

nettofarah added a commit that referenced this pull request Dec 23, 2015
@nettofarah nettofarah merged commit 4c87d29 into IFTTT:master Dec 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants