Module: Ruson::Json
- Included in:
- Base
- Defined in:
- lib/ruson/json.rb
Instance Method Summary collapse
- #get_hash_from_json(json) ⇒ Object
-
#id_from_file_path(path) ⇒ Object
Returns the ID from the JSON file path.
Instance Method Details
#get_hash_from_json(json) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/ruson/json.rb', line 3 def get_hash_from_json(json) return unless json return json if json.class == ActiveSupport::HashWithIndifferentAccess (json.class == Hash ? json : JSON.parse(json)).with_indifferent_access end |
#id_from_file_path(path) ⇒ Object
Returns the ID from the JSON file path.
13 14 15 |
# File 'lib/ruson/json.rb', line 13 def id_from_file_path(path) File.basename(path, '.json').to_i end |