Created
September 22, 2011 23:23
-
-
Save sbellware/1236327 to your computer and use it in GitHub Desktop.
Transformer Prototype
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Foo | |
| attr_accessor :bar | |
| end | |
| foo = Foo.new | |
| foo.bar = 'blah' | |
| transformer = Transformer.build :foo | |
| transformed_foo = transformer.transform foo | |
| # needs: | |
| # transform the class name (Foo) into whatever if necessary | |
| # transform the attribute name (bar) into whatever if necessary | |
| class Transformer | |
| attr_accessor :subject | |
| def transform | |
| transform_class_name(subject_name) | |
| transform_attribute_names(subject_attribute_name) | |
| end | |
| def transform_class_name(name) | |
| # find lambdas for this class, execute them | |
| end | |
| def transform_attribute_names(names) | |
| transform_attribute_name(name) | |
| end | |
| def transform_attribute_name(name) | |
| # find lambdas for this attribute, execute them | |
| end | |
| def class_name_transformations(name) | |
| # return [global lambdas, global class name lambdas, specific class name lambdas] | |
| end | |
| def attribute_name_transformations(name) | |
| # return [global lambdas, global attribute name lambdas, specific attribute name lambdas] | |
| end | |
| end | |
| # - all strings | |
| # |- all class names | |
| # |- all attribute names | |
| # |- specific class names | |
| # |- specific attribute names for this specific class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment