Skip to content

Instantly share code, notes, and snippets.

@SixArm
Created November 29, 2014 06:37
Show Gist options
  • Save SixArm/ccbd5429af3a1538e5e9 to your computer and use it in GitHub Desktop.
Save SixArm/ccbd5429af3a1538e5e9 to your computer and use it in GitHub Desktop.
Exportable example with project and items
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