Module: Operable::ClassMethods
- Defined in:
- lib/operable.rb
Constant Summary collapse
- INOPERABLE_FIELDS =
%w[_type _id id created_at updated_at version]
Instance Method Summary collapse
Instance Method Details
#operable_on(*names) ⇒ Object
21 22 23 24 |
# File 'lib/operable.rb', line 21 def operable_on(*names) fields = operable_fields || [] self.operable_fields = [fields, names].flatten.map(&:to_s).uniq.sort end |
#operable_on_all ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/operable.rb', line 26 def operable_on_all if respond_to?(:fields) self.operable_fields = fields.keys.reject {|k| INOPERABLE_FIELDS.include? k } elsif respond_to?(:columns) self.operable_fields = columns.select do |c| [:integer, :float, :decimal].include? c.type end.map(&:name).reject {|k| INOPERABLE_FIELDS.include? k } else raise "Unable to list all fields for this ORM" end end |
#operable_on_all_except(*names) ⇒ Object
38 39 40 |
# File 'lib/operable.rb', line 38 def operable_on_all_except(*names) self.operable_fields = operable_on_all.reject {|k| names.map(&:to_s).include? k } end |