Module: AngryHash::Extension::ClassMethods

Defined in:
lib/angry_hash/extension.rb

Instance Method Summary collapse

Instance Method Details

#build(seed = {}) ⇒ Object



182
183
184
185
186
187
# File 'lib/angry_hash/extension.rb', line 182

def build(seed={})
  AngryHash[ seed ].tap {|hash|
    self.fill_in_defaults(hash)
    hash.extend self
  }
end

#defaults(default_form = nil) ⇒ Object



152
153
154
155
156
157
# File 'lib/angry_hash/extension.rb', line 152

def defaults(default_form=nil)
  if default_form
    @default_form = default_form
  end
  @default_form
end

#extend_array(field, mod, options = {}) ⇒ Object



169
170
171
# File 'lib/angry_hash/extension.rb', line 169

def extend_array(field,mod,options={})
  Extension.register_mixin_array(self,field,mod,options)
end

#extend_hash(field, mod, options = {}) ⇒ Object



173
174
175
# File 'lib/angry_hash/extension.rb', line 173

def extend_hash(field,mod,options={})
  Extension.register_mixin_hash(self,field,mod,options)
end

#extend_self(options = {}, &block) ⇒ Object



177
178
179
180
# File 'lib/angry_hash/extension.rb', line 177

def extend_self(options={}, &block)
  options[:block] = block
  Extension.register_mixin_block(self,options)
end

#extend_value(field, mod, options = {}) ⇒ Object



165
166
167
# File 'lib/angry_hash/extension.rb', line 165

def extend_value(field,mod,options={})
  Extension.register_mixin(self,field,mod,options)
end

#fill_in_defaults(hash) ⇒ Object



159
160
161
162
163
# File 'lib/angry_hash/extension.rb', line 159

def fill_in_defaults(hash)
  if defaults
    hash.reverse_deep_update(defaults)
  end
end