Sha256: f6c7a31808916f3757af62531e6f4eea91820107207dc9f9d650fcc7aa36c47b
Contents?: true
Size: 1.06 KB
Versions: 105
Compression:
Stored size: 1.06 KB
Contents
class MLS::Property DEFAULT_OPTIONS = { :serialize => :always } attr_reader :model, :name, :instance_variable_name, :options, :default attr_reader :reader_visibility, :writer_visibility def initialize(name, options={}) @name = name @instance_variable_name = "@#{@name}".freeze @options = DEFAULT_OPTIONS.merge(options) set_default_value determine_visibility end def set_default_value @default = @options[:default] end def determine_visibility # default :public @reader_visibility = @options[:reader] || :public @writer_visibility = @options[:writer] || :public end def self.determine_class(type) return type if type < MLS::Property find_class(::ActiveSupport::Inflector.demodulize(type)) end def self.inherited(descendant) demodulized_names[::ActiveSupport::Inflector.demodulize(descendant.name)] ||= descendant end def self.demodulized_names @demodulized_names ||= {} end def self.find_class(name) klass = demodulized_names[name] klass ||= const_get(name) if const_defined?(name) klass end end
Version data entries
105 entries across 105 versions & 1 rubygems