Comments (1)
Hmm... I'm not sure whether adding domain logic to what basically is a reader is a good idea (have a look at this talk: http://www.youtube.com/watch?feature=player_embedded&v=WpkDN78P884 ). I would attempt to keep it completely separate from domain logic and use workbook as a gem in your project, not the base of your project (and if you need specific functionality think whether it belongs in this gem or not (and in the case of StringIO it does fit)). However, if you still feel there is a need... I kind of think there is a smell to the first option with splitting names on '::' that I don't like... I would be ok with taking patches for option 2 but I'd first reconsider whether adding domain logic is a good thing in the first place (you can mail me if you prefer).
Op 12 apr. 2013, om 20:22 heeft kianw [email protected] het volgende geschreven:
One thing I was mulling over was how to subclass Workbook in order to add domain-specific functionality to the classes. I didn't want to monkey-patch your classes, as we may need more than one domain with different functionality, so subclassing seems the way to go.
The issue I was running into was that if I subclass Workbook::Book and Workbook::Sheet, for example, my Workbook::Book subclass will still use the super-classes, such as creating a Workbook::Sheet in #initialize or #push (instead of my new Sheet subclass). Short of overriding every method that references one of the other Workbook classes (ugh), there doesn't appear to be any way to easily do this right now (maybe I'm missing something obvious?).
Two solutions spring to mind: 1) create a new module for each domain, with classes that inherit from Workbook classes. And modify Workbook so that every reference to the Workbook constant is changed to something like self.class.const_get(self.class.name.split('::')[0..-2].join), which would get the module for self. We'd probably put that code in a helper method.
Or 2) replace (in Workbook) every reference to a Workbook class constant (e.g., Workbook::Sheet) with a call to a helper method that returns the class constant. Then when you subclass a Workbook class, you just need to override those helper methods to point to your subclasses instead of the base Workbook classes.
These options are fairly similar; option 1 has the advantage of putting the subclasses into a new module (although you could do that with option 2 also), and it doesn't require you to override any methods. option 2 is probably a bit simpler.
Any ideas or feedback?
—
Reply to this email directly or view it on GitHub.
from workbook.
Related Issues (11)
- Column support, e.g. t[:b] could then return Workbook::Column<[,,]> HOT 1
- Return values, instead of cells with values, that have additional workbook-related methods HOT 1
- Export actual dates in XLSX-export (currently a ISO-date string is exported) HOT 1
- Access sheet by sheet symbolized sheet name (like header)
- Add option to consider empty strings as nils HOT 1
- Update to 0.4.3 and can't open workbooks
- Workbook depends on GPLv3 code HOT 2
- Make (e.g.) CSV converters configurable
- Make date-parser configurable
- Improve XLSX export support
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 workbook.