Sha256: 5ca3256e2d8e400c261a6bd817ac06558a5daa514c47dd721be7d540daccc1dd

Contents?: true

Size: 648 Bytes

Versions: 2

Compression:

Stored size: 648 Bytes

Contents

class Rhapsody::Member
  require 'json'

  attr_accessor :attr_list

  class << self
    # TODO: This needs to be global / base
    def define_attr_accessor(key)
      __send__(:attr_accessor, key)
    end

    def to_camelcase(key)
      key.to_s.underscore
    end
  end

  def initialize(options)
    if options
      self.attr_list = []

      options.each do |key, value|
        key = Rhapsody::Member.to_camelcase(key)

        # Set attr_accessor dynamically
        Rhapsody::Member.define_attr_accessor(key)
        self.attr_list << key

        # Set value for the attribute
        send("#{key}=", value)
      end
    end
  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rhapsody-0.0.11 lib/rhapsody/models/member.rb
rhapsody-0.0.10 lib/rhapsody/models/member.rb