Sha256: ec34ba845347e6d02764c871b4698e2bd33c6ac4e9f95121bc684f459712eae9
Contents?: true
Size: 804 Bytes
Versions: 23
Compression:
Stored size: 804 Bytes
Contents
module Unimatrix class DynamicResource < Resource class << self alias old_new new def new( attributes = {}, associations = {} ) Class.new( self ).old_new( { type_name: self.name.split( '::' ).last.underscore }. merge( attributes ), associations ) end end def initialize( attributes = {}, associations = {} ) unsupported_attributes_names = [] attributes.each do | key, value | unsupported_attributes_names << key.to_sym \ unless self.respond_to?( key.to_sym ) end self.class_eval do unsupported_attributes_names.each do | name | field name end end super( attributes, associations ) yield self if block_given? end end end
Version data entries
23 entries across 23 versions & 1 rubygems