Sha256: f335bb040d66f92eb1c999cd56cf4ee93e544ff05c49b137a5c613a3e4167807
Contents?: true
Size: 834 Bytes
Versions: 2
Compression:
Stored size: 834 Bytes
Contents
# Models a Rails model. require 'katapult/element' require 'katapult/attribute' require 'generators/katapult/model/model_generator' module Katapult class Model < Element UnknownAttributeError = Class.new(StandardError) attr_accessor :attrs def initialize(*args) self.attrs = [] super end def attr(attr_name, options = {}) attrs << Attribute.new(attr_name, options) end def label_attr renderable_attrs.first end def db_fields attrs.reject(&:skip_db) end def renderable_attrs attrs.reject { |a| %w[plain_json json password].include? a.type.to_s } end def editable_attrs attrs.reject { |a| %w[plain_json json].include? a.type.to_s } end def render Generators::ModelGenerator.new(self).invoke_all end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
katapult-0.3.0 | lib/katapult/model.rb |
katapult-0.2.0 | lib/katapult/model.rb |