Sha256: 8e5254d875677e6d71cdad25ff21b33bb9d98a8138e4b30be7acf46b868111e6

Contents?: true

Size: 793 Bytes

Versions: 29

Compression:

Stored size: 793 Bytes

Contents

module Arrest
  class Attribute
    attr_accessor :name, :read_only, :clazz, :json_name
    def initialize name, read_only, clazz
      @name = name.to_sym
      @read_only = read_only
      @clazz = clazz
      @json_name = Source.json_key_converter.key_to_json(name).to_sym
    end

    def from_hash(parent, value)
      return if value == nil
      converter = CONVERTER[@clazz]
      if converter == nil
        puts "No converter for: #{@clazz.name}"
        converter = IdentConv
      end
      converter.convert value
    end

    def to_hash value
      return nil unless value != nil
      converter = CONVERTER[@clazz]
      if converter == nil
        puts "No converter for: #{@clazz.name}"
        converter = IdentConv
      end
      converter.mk_json value
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
arrest-0.0.32 lib/arrest/attributes/attribute.rb
arrest-0.0.31 lib/arrest/attributes/attribute.rb
arrest-0.0.30 lib/arrest/attributes/attribute.rb
arrest-0.0.29 lib/arrest/attributes/attribute.rb
arrest-0.0.28 lib/arrest/attributes/attribute.rb
arrest-0.0.27 lib/arrest/attributes/attribute.rb
arrest-0.0.25 lib/arrest/attributes/attribute.rb
arrest-0.0.24 lib/arrest/attributes/attribute.rb
arrest-0.0.23 lib/arrest/attributes/attribute.rb