Class: BitmaskEnum::Attribute Private

Inherits:
Object
  • Object
show all
Defined in:
lib/bitmask_enum/attribute.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constructs the magic methods and overrides getters and setters for a bitmask enum attribute

Instance Method Summary collapse

Constructor Details

#initialize(model, attribute, flags, options, defined_enum_methods) ⇒ Attribute

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Attribute.



12
13
14
15
16
17
18
19
# File 'lib/bitmask_enum/attribute.rb', line 12

def initialize(model, attribute, flags, options, defined_enum_methods)
  @attribute = attribute
  @flags = flags
  @options = Options.new(options)
  @nil_handler = NilHandler.new(@options.nil_handling)
  @model = model
  @conflict_checker = ConflictChecker.new(model, attribute, defined_enum_methods)
end

Instance Method Details

#construct!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Defines the methods for the attribute



22
23
24
25
26
27
28
29
30
31
# File 'lib/bitmask_enum/attribute.rb', line 22

def construct!
  attribute_validation if @options.validate

  @flags.each_with_index do |flag, flag_index|
    per_flag_methods("#{@options.flag_prefix}#{flag}#{@options.flag_suffix}", flag_index)
  end

  instance_level_methods
  class_level_methods
end