class Formup::Source
Attributes
attribute_defs[RW]
key[RW]
Public Class Methods
new(key, attribute_defs = {}, excludes = nil)
click to toggle source
# File lib/formup/source.rb, line 10 def initialize(key, attribute_defs = {}, excludes = nil) raise "Formup::Source require key param." if key.nil? @key = key.to_s @attribute_defs = attribute_defs.map { |k, v| Formup::AttrDef.new(k, v) } if attribute_defs @attribute_defs ||= [] end
Public Instance Methods
attr(base)
click to toggle source
# File lib/formup/source.rb, line 31 def attr(base) attr_def = @attribute_defs.detect { |attr_def| attr_def.base == base.to_s } attr_def ? attr_def.attr : nil end
attr?(attr)
click to toggle source
# File lib/formup/source.rb, line 27 def attr?(attr) @attribute_defs.any? { |attr_def| attr_def.attr == attr.to_s } end
base(attr)
click to toggle source
# File lib/formup/source.rb, line 22 def base(attr) attr_def = @attribute_defs.detect { |attr_def| attr_def.attr == attr.to_s } attr_def ? attr_def.base : nil end
base?(base)
click to toggle source
# File lib/formup/source.rb, line 18 def base?(base) @attribute_defs.any? { |attr_def| attr_def.base == base.to_s } end