module HasProperties

Attributes

props[RW]
require_attrs[RW]

Public Class Methods

included(base) click to toggle source
# File lib/gpack/core/GitReference.rb, line 15
def self.included base
   base.extend self
end
new(args) click to toggle source
# File lib/gpack/core/GitReference.rb, line 19
def initialize(args)

   # Attributes required when defining a GitReference
   require_attrs = self.class.require_attrs

   # Check that all the required
   args.each do |k,v|
      require_attrs = require_attrs - [k]
   end
   
   if require_attrs.any?
      raise "Must include attributes #{require_attrs} in GitReference definition"
   end

   args.each {|k,v|
      instance_variable_set "@#{k}", v if self.class.props.member?(k)
   } if args.is_a? Hash
end

Public Instance Methods

has_properties(*args) click to toggle source
# File lib/gpack/core/GitReference.rb, line 5
def has_properties *args
   @props = args
   instance_eval { attr_reader *args }
   instance_eval { attr_writer *args }
end
has_required(*args) click to toggle source
# File lib/gpack/core/GitReference.rb, line 11
def has_required *args
   @require_attrs = args
end