Module: Adjective::Imbibable
- Defined in:
- lib/modules/imbibable.rb
Class Method Summary collapse
Instance Method Summary collapse
- #define_imbibable_instance_variables(args) ⇒ Object
- #imbibable_default_data ⇒ Object
- #init_imbibable(args = {}, &block) ⇒ Object
Class Method Details
.adjective_add_columns(klass) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/modules/imbibable.rb', line 32 def self.adjective_add_columns(klass) columns = <<-RUBY # Imbibable Attributes add_column {{klass}}, :total_experience, :integer add_column {{klass}}, :level, :integer RUBY columns.gsub("{{klass}}", ":#{klass.downcase}") end |
.adjective_columns ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/modules/imbibable.rb', line 24 def self.adjective_columns <<-RUBY # Vulnerable Attributes t.integer :total_experience t.integer :level RUBY end |
Instance Method Details
#define_imbibable_instance_variables(args) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/modules/imbibable.rb', line 17 def define_imbibable_instance_variables(args) args.each do |key, value| self.class.send(:attr_accessor, key) self.instance_variable_set("@#{key.to_s}", value) end end |
#imbibable_default_data ⇒ Object
10 11 12 13 14 15 |
# File 'lib/modules/imbibable.rb', line 10 def imbibable_default_data { experience: 0, level: 1 } end |
#init_imbibable(args = {}, &block) ⇒ Object
4 5 6 7 8 |
# File 'lib/modules/imbibable.rb', line 4 def init_imbibable(args = {}, &block) if !Adjective.configuration.use_active_record define_imbibable_instance_variables(imbibable_default_data) end end |