Sha256: 55292a716a045fe1c6167d697c83ff9f01121072fab25ec2653050cd728ab533
Contents?: true
Size: 1.51 KB
Versions: 4
Compression:
Stored size: 1.51 KB
Contents
# frozen_string_literal: true module Kaui module RailsMethods def self.included(base_class) base_class.class_eval do # Required to build urls in views extend ActiveModel::Naming include ActiveModel::Validations # Required to make form_for work include ActiveModel::Conversion def ==(other) !other.nil? && self.class == other.class && to_hash == other.to_hash end def persisted? # Hard to know... false end def new_record? !persisted? end def to_param # Hard to know (depends on the model)... nil end def read_attribute_for_validation(attr) send(attr) end def save @errors.add(:save, 'Saving this object is not yet supported') false end def update_attributes(_tag_definition) @errors.add(:update, 'Updating this object is not yet supported') false end def destroy @errors.add(:destroy, 'Destroying this object is not yet supported') false end end base_class.instance_eval do def self.human_attribute_name(attr, _options = {}) attr end def self.lookup_ancestors [self] end def self.all [] end def self.count all.count end def self.find(_id) nil end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
kaui-3.0.4 | app/models/kaui/rails_methods.rb |
kaui-3.0.2 | app/models/kaui/rails_methods.rb |
kaui-2.2.1 | app/models/kaui/rails_methods.rb |
kaui-3.0.1 | app/models/kaui/rails_methods.rb |