Module: BitAttrs::ClassMethods
- Defined in:
- lib/bit_attrs.rb
Instance Attribute Summary collapse
-
#bit_attrs ⇒ Object
readonly
Returns the value of attribute bit_attrs.
Instance Method Summary collapse
-
#bitset(flags_map) ⇒ Object
bitset roles: [:admin, :user, :guest] bitset access_levels: [read: 0, write: 1, delete: 2, api: 3].
Instance Attribute Details
#bit_attrs ⇒ Object (readonly)
Returns the value of attribute bit_attrs.
14 15 16 |
# File 'lib/bit_attrs.rb', line 14 def bit_attrs @bit_attrs end |
Instance Method Details
#bitset(flags_map) ⇒ Object
bitset roles: [:admin, :user, :guest] bitset access_levels: [read: 0, write: 1, delete: 2, api: 3]
18 19 20 21 22 23 24 25 26 |
# File 'lib/bit_attrs.rb', line 18 def bitset(flags_map) @bit_attrs ||= {} flags_map.each do |attr_name, flags_list| @bit_attrs[attr_name] = check_flags_list(flags_list) define_alias_methods(attr_name, @bit_attrs[attr_name]) Bindings.create(self, attr_name) end end |