Class: Packager::Struct
- Inherits:
-
Struct
- Object
- Struct
- Packager::Struct
- Defined in:
- lib/packager/struct.rb
Overview
This exists so that you can pass in a Hash or an Array. While passing an Array can be useful, passing in a Hash is far more self-documenting.
Defined Under Namespace
Classes: Command, File, Package
Instance Method Summary collapse
-
#initialize(*args) ⇒ Struct
constructor
A new instance of Struct.
Constructor Details
#initialize(*args) ⇒ Struct
Returns a new instance of Struct.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/packager/struct.rb', line 6 def initialize(*args) if args.length == 1 and args[0].instance_of?(Hash) difference = Set.new(args[0].keys) - Set.new(self.class.members) unless difference.empty? raise 'Passed in unknown params: ' + difference.to_a.sort.join(', ') end super(*args[0].values_at(*self.class.members)) else super(*args) end end |