Object
This is the abstract base class for all data objects.
The arg extractor for this class.
# File lib/bindata/base.rb, line 56 def arg_extractor BaseArgExtractor end
Resets the internal state to that of a newly created object.
# File lib/bindata/base.rb, line 158 def clear initialize_instance end
Returns the result of evaluating the parameter identified by key.
overrides is an optional parameters like hash that allow the parameters given at object construction to be overridden.
Returns nil if key does not refer to any parameter.
# File lib/bindata/base.rb, line 131 def eval_parameter(key, overrides = nil) value = get_parameter(key) if value.is_a?(Symbol) or value.respond_to?(:arity) lazy_evaluator.lazy_eval(value, overrides) else value end end
Returns the parameter referenced by key. Use this method if you are sure the parameter is not to be evaluated. You most likely want eval_parameter.
# File lib/bindata/base.rb, line 148 def get_parameter(key) @params[key] end
Returns whether key exists in the parameters hash.
# File lib/bindata/base.rb, line 153 def has_parameter?(key) @params.has_parameter?(key) end
# File lib/bindata/deprecated.rb, line 26 def initialize_instance(*args) unless args.empty? fail "#{caller[0]} remove the call to super in #initialize_instance" end end
# File lib/bindata/deprecated.rb, line 13 def initialize_with_warning(*args) owner = method(:initialize).owner if owner != BinData::Base msg = "Don't override #initialize on #{owner}." if %(BinData::Base BinData::BasePrimitive).include? self.class.superclass.name msg += "\nrename #initialize to #initialize_instance." end fail msg end initialize_without_warning(*args) end
Don’t override initialize. If you are defining a new kind of datatype (list, array, choice etc) then put your initialization code in initialize_instance. This is because BinData objects can be initialized as prototypes and your initialization code may not be called.
If you’re subclassing BinData::Record, you are definitely doing the wrong thing. Read the documentation on how to use BinData. bindata.rubyforge.org/manual.html#records
Creates a new data object based on this instance.
All parameters will be be duplicated. Use this method when creating multiple objects with the same parameters.
# File lib/bindata/base.rb, line 116 def new(value = nil, parent = nil) obj = clone obj.parent = parent if parent obj.initialize_instance obj.assign(value) if value obj end
Generated with the Darkfish Rdoc Generator 2.