Created
November 29, 2014 06:37
-
-
Save SixArm/ccbd5429af3a1538e5e9 to your computer and use it in GitHub Desktop.
Exportable example with project and items
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
require_relative 'exportable' | |
class Project | |
include Exportable | |
attr_accessor :name | |
attr_accessor :description | |
attr_accessor :items | |
def initialize(args) | |
@name, @description, @items = args.values | |
end | |
def export_value | |
[export_send(:name), export_send(:description), export_enumerable(:items)].join | |
end | |
end | |
class Item | |
include Exportable | |
attr_accessor :name | |
attr_accessor :description | |
def initialize(args) | |
@name, @description = args.values | |
end | |
def export_value | |
[export_send(:name), export_send(:description)].join | |
end | |
end | |
item_1 = Item.new(name: "A", description: "B") | |
item_2 = Item.new(name: "C", description: "D") | |
project = Project.new(name: "E", description: "F", items: [item_1, item_2]) | |
project.export |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment