Sha256: 77737a531d990925a5bc20360a8fdbd26065d947b0b5d9c87d4cc736fec840c3

Contents?: true

Size: 593 Bytes

Versions: 14

Compression:

Stored size: 593 Bytes

Contents

module Centaman
  #:nodoc:
  class Object
    def initialize(args = {})
      define_variables(args)
      after_init(args)
    end

    def define_variables(args)
      attributes.each do |attribute|
        val = args[attribute.centaman_key]
        attribute.value = val
        attribute.parse_value
        self.class.__send__(:attr_accessor, attribute.app_key)
        instance_variable_set("@#{attribute.app_key}", attribute.value)
      end
    end

    def attributes
      [] # overwritten by subclasses
    end

    def after_init(args)
      # hook for subclasses
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
centaman-0.1.13 lib/centaman/object.rb
centaman-0.1.12 lib/centaman/object.rb
centaman-0.1.11 lib/centaman/object.rb
centaman-0.1.10 lib/centaman/object.rb
centaman-0.1.9 lib/centaman/object.rb
centaman-0.1.8 lib/centaman/object.rb
centaman-0.1.7 lib/centaman/object.rb
centaman-0.1.6 lib/centaman/object.rb
centaman-0.1.5 lib/centaman/object.rb
centaman-0.1.4 lib/centaman/object.rb
centaman-0.1.3 lib/centaman/object.rb
centaman-0.1.2 lib/centaman/object.rb
centaman-0.1.1 lib/centaman/object.rb
centaman-0.1.0 lib/centaman/object.rb